dtdetu Posted November 16, 2008 Share Posted November 16, 2008 Hello how can i get the 10 from this code: (10:1)<br /> i tried this but didnt work, can someone help, thanks preg_match("~((.*?):1)~i", $string, $result); Quote Link to comment Share on other sites More sharing options...
ddrudik Posted November 16, 2008 Share Posted November 16, 2008 PHP Code Example: <?php $sourcestring="your source string"; preg_match_all('/\((\d+):\d+\)/',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?> $matches Array: ( [0] => Array ( [0] => (10:1) ) [1] => Array ( [0] => 10 ) ) Quote Link to comment Share on other sites More sharing options...
.josh Posted November 16, 2008 Share Posted November 16, 2008 "/\((.*):/" Quote Link to comment Share on other sites More sharing options...
dtdetu Posted November 16, 2008 Author Share Posted November 16, 2008 "/\((.*):/" i need to use ( and ) too otherwise it finds lots of things in html code, i am searching a html page not only that string:) also ddrudik it didnt work for me now also i dont need (10:1) it shouldnt be included in array. can u check again thanks Quote Link to comment Share on other sites More sharing options...
.josh Posted November 16, 2008 Share Posted November 16, 2008 well you posted a certain string regex is based off that specific string. Anyways, ddrudik's regex should work for you regardless. Look at his array dump. Quote Link to comment Share on other sites More sharing options...
dtdetu Posted November 16, 2008 Author Share Posted November 16, 2008 ok it works with the only (10:1) but when i use it on page it gives blank arrays, the string is like this Germany and 2 is variable, 1 is stable, i want to get the 2 <td>Germany (2 : 1)</td> Quote Link to comment Share on other sites More sharing options...
dtdetu Posted November 16, 2008 Author Share Posted November 16, 2008 sorry i was making a mistake thats why it didnt work, thank you both sorry for mistake 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.