adv Posted December 6, 2007 Share Posted December 6, 2007 <?php $nume=""; $str="<span>welcome </span><span class=blu12 style=font-weight: bold;>name lastname</span>"; preg_match('/<span>(.*?)<\/span><span>(.*?)<\/span>/', $str, $al); if(count($al) != 0) { $nume = $al[1]; } echo $nume; ?> dunno how to quite put this as u see from my code .. i want to echo welcome name lastname ; but dunno how preg_match quite works . from the first span to the last span to echo it Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 6, 2007 Share Posted December 6, 2007 are you trying to extract the data from the string ? if so this should work <?php $nume=""; $str="<span>welcome </span><span class=blu12 style=font-weight: bold;>name lastname</span>"; preg_match('/<span[^>]+(.*?)<\/span>/', $str, $al); if(count($al) != 0) { $nume = $al[0]; } echo $nume; ?> Quote Link to comment Share on other sites More sharing options...
adv Posted December 6, 2007 Author Share Posted December 6, 2007 yes that is the trick .. i can`t just understand how with all the signs ]^*() (.*?) where ca i find all this signs explicationss? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 6, 2007 Share Posted December 6, 2007 you can checkout the following link http://php.net/preg_match Quote Link to comment Share on other sites More sharing options...
adv Posted December 6, 2007 Author Share Posted December 6, 2007 i tried that .. nothing .. Quote Link to comment Share on other sites More sharing options...
effigy Posted December 6, 2007 Share Posted December 6, 2007 See the Resources. There's a cheat sheet there. Quote Link to comment Share on other sites More sharing options...
adv Posted December 7, 2007 Author Share Posted December 7, 2007 thanks alot effigy 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.