this is my question:
suppose i have a html element
can any give me the regular expression to get value1 and value2 from the element?
thanks really much appreciated
Started on the old forum in September 2010 · view the original in the archive · old links redirect here
this is my question:
suppose i have a html element
can any give me the regular expression to get value1 and value2 from the element?
thanks really much appreciated
thanks for trying but thats not what am taking about, i am talking removing the the value of the attributes from the element
so if i have value2
i want to get value1 and value2 from the string using some preg_match or some preg_replace its the regular expression that i dont knw
$value1 = explode(""", $all_html_here); $value1 = $value1[1];
Like this?
mysterio.al - programming is a functional art
$s = "<a href='value1'>value2</a>";
preg_match("/<a href=[\"|'](.*)[\"|']>(.*)<\/a>/i", $s, $m);
print_r($m);
output will be:
Array
(
[0] => <a href='value1'>value2</a>
[1] => value1
[2] => value2
)
Advertise your mobile site for FREE with AdTwirl
thank you very much gumslone, that is what i am looking for, thanks alot
Added after 44 minutes:
<?php
echo '<br/> link';
$s = '<a href="value1">value2</a>';
preg_match("/<a href=[\"|'](.*)[\"|']>(.*)<\/a>/i", $s, $m);
print_r($m);
echo '<br/> image';
$image = '<img src="value1" alt="value2"/>';
preg_match("/<img src=[\"|'](.*)[\"|] alt=[\"|'](.*)[\"|']\/>/i", $image, $t);
print_r($t);
echo '<br/> image link';
$imagelink = '<a href="link"><img src="image source" alt="image title"/></a>';
preg_match("/<a href=[\"|'](.*)[\"|']><img src=[\"|'](.*)[\"|] alt=[\"|'](.*)[\"|']\/><\/a>/i", $imagelink, $v);
print_r($v);
?>
mob_mate wrote: What abt other commenter?
There are some users here, who made half questions, then let us guess what the question is and find a right answer. But how?
mysterio.al - programming is a functional art