homer.favenir Posted May 26, 2009 Share Posted May 26, 2009 hi, i want to extract the text inside "<" and ">" e.g. $str = '<statex refid="ALRdi335-14">, which means Alabama Regulations, Division 335-14 </statex>'; i want to extract "statex refid="ALRdi335-1" in $str i tried $str = '<statex refid="ALRdi335-14">, which means Alabama Regulations, Division 335-14</statex>'; $strt_tag = strpos($str, "<"); $end_tag = strpos($str, ">"); echo substr($str, $strt_tag, $end_tag); but it returns nothing... can you help me please... thanks Link to comment https://forums.phpfreaks.com/topic/159677-htmlentities/ Share on other sites More sharing options...
zq29 Posted May 26, 2009 Share Posted May 26, 2009 I'd go with Regular Expressions, using something like preg_match_all(). <?php preg_match_all("/<(.*)>/",$str,$m); echo "<pre>",print_r($m),"</pre>"; ?> EDIT: What's with the topic title? This has nothing to do with HTML entities... Link to comment https://forums.phpfreaks.com/topic/159677-htmlentities/#findComment-842193 Share on other sites More sharing options...
homer.favenir Posted May 27, 2009 Author Share Posted May 27, 2009 i want to extract "statex refid="ALRdi335-1" inside < and > Link to comment https://forums.phpfreaks.com/topic/159677-htmlentities/#findComment-842822 Share on other sites More sharing options...
BK87 Posted May 27, 2009 Share Posted May 27, 2009 <? $str = '<statex refid="ALRdi335-14">, which means Alabama Regulations, Division 335-14</statex>'; preg_match("/<statex refid=\"(.*)\">/",$str,$out); echo $out[1]; ?> this will display the actual "id" in refid tag. since we already know how it will come out... Link to comment https://forums.phpfreaks.com/topic/159677-htmlentities/#findComment-842845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.