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 Quote Link to comment 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... Quote Link to comment 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 > Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.