Jump to content

removing text from a php variable


needphphelp22

Recommended Posts

Assuming that you ONLY want the content in the SPAN tags and there is nothing outside the SPAN tags you need, then I'd use preg_match to just find the text within the SPAN tags.

 

$testv = '<span id="sobi2Details_field_street">www.google.com</span>';

preg_match("#<span[^>]*>(.*)</span>#", $testv, $matches);
$spanContent = $matches[1];
echo $spanContent; //Output: www.google.com

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.