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 Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/ 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; ?> Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/#findComment-407849 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? Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/#findComment-407868 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 Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/#findComment-407871 Share on other sites More sharing options...
adv Posted December 6, 2007 Author Share Posted December 6, 2007 i tried that .. nothing .. Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/#findComment-408032 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. Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/#findComment-408038 Share on other sites More sharing options...
adv Posted December 7, 2007 Author Share Posted December 7, 2007 thanks alot effigy Link to comment https://forums.phpfreaks.com/topic/80442-solved-preg_match-help/#findComment-408840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.