I don't really understnd how to work with this preg_match,
but I think it can do what I need easily...
I need him to echo back only the text that is inside for example
two <b> signs or <sdfg> signs or what ever sign I will give him...
Does anyone know's how to do that?
s_ha_dum (was apljdi)
Member
Posted 2 years ago #
$test = '<html><head></head><body><p>hi</p><p><b >hello</b><b>Goodbye</b></p></body></html>';
preg_match_all("#<b\b[^>]*>(.*?)</b\b[^>]*>#",$test,$matches);
print_r($matches);
This is very basic and not very robust. A tag like < b> will throw it off though <b > won't. Basically the syntax comes from here.
Great! thank's.
But i can't get it completly working as I want:
I wrote:
$preprice = "text text text <price>34</price> more text text text";
preg_match_all("#<price\b[^>]*>(.*?)</price>#", $preprice, $matches);
$price = "$matches";
add_post_meta($post_ID, 'price', $price);
and it add a post meta with a value "array" and not "34"
as I want...
?
I got it right, thank's!!! it's just great!!!