damanman Posted February 7, 2011 Share Posted February 7, 2011 I need to remove some text from a php variable.right now $testv = <span id="sobi2Details_field_street">www.google.com</span>I need to remove the <span id="sobi2Details_field_street"> and the </span> so im left with$testv = www.google.com Link to comment Share on other sites More sharing options...
thescientist Posted February 7, 2011 Share Posted February 7, 2011 ok... is there a special way this text is being generated, that you don't have control over? Link to comment Share on other sites More sharing options...
damanman Posted February 7, 2011 Author Share Posted February 7, 2011 yea, i am using joomla with sobi2 a directory application<?php $testv=$fieldsFormatted['field_street']; ?> Link to comment Share on other sites More sharing options...
Synook Posted February 7, 2011 Share Posted February 7, 2011 In the case you can just use strip_tags(), but more generally regular expressions would be used for this type of manipulation. Link to comment Share on other sites More sharing options...
jeffman Posted February 7, 2011 Share Posted February 7, 2011 Hah. Forgot about strip_tags. I was going to suggest this: $myElement = '<span id="sobi2Details_field_street">www.google.com</span>';$doc = new DOMDocument();$doc->loadHTML($myElement);echo $doc->textContent; Link to comment Share on other sites More sharing options...
justsomeguy Posted February 7, 2011 Share Posted February 7, 2011 If you're getting that text from an array called $fieldsFormatted, there might also be an unformatted version already available. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.