adv Posted April 19, 2008 Share Posted April 19, 2008 this is my problem <span>Welcome </span><span class="blu10" style="font-weight:bold;">name1 name</span> and with preg_match i`ve tried to show "Welcome name1 name2" if (strstr($result,"<span>Welcome")) { preg_match('/<span>(.*?)<\/span><span(.*?)<\/span>/', $result, $al); if(count($al) != 0) { $nume = $al[1]; $nome = $nume; $_SESSION['ben']= $nome; } } but it doesnt work ..i`ve echo it and i see only Welcome and another problem <span><br />You have been here for </span> <span>2 days , 30 min ,</span> and i want to exact "You have been here for 2 day , 30 min i`ve tried with this : if (strstr($result,"<span><br />You have been here for</span>")) { preg_match('/<span><br />You have been here for</span><span>(.*?)<\/span>/', $result, $al); if(count($al) != 0) { $check = $al[1]; $check1 = $check; $_SESSION['check'] = $check1; } } thanks in advance Quote Link to comment Share on other sites More sharing options...
adv Posted April 20, 2008 Author Share Posted April 20, 2008 someone .... Quote Link to comment Share on other sites More sharing options...
adv Posted April 20, 2008 Author Share Posted April 20, 2008 pff i finally figure it out .. i works without the count() ; $pattern = "/<span>(.*?)<\/span><span(.*?)<\/span>/"; if (strstr($result,"<span>Welcome")) { preg_match($pattern, $result, $al); $test = $al[0]; } echo $test; and it works good now .. thanks anyway Quote Link to comment Share on other sites More sharing options...
aCa Posted April 21, 2008 Share Posted April 21, 2008 Hmm took a look at you code. Wont you get the additional span class data etc also included in your result? if (preg_match('/<span>(.*?)<\/span><span.*?>(.*?)<\/span>/i', '<span>Welcome </span><span class="blu10" style="font-weight:bold;">name1 name</span>', $result)) { echo $result[1].$result[2]; } Wouldn't this give you the result you requested? You have probably figured out your other problem and one of many ways to get the time is with a pattern like this: $pattern = '<span>(?=\d)(.*?)<\/span>'; 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.