Guest Posted November 5, 2006 Posted November 5, 2006 Im trying to write a function in php that will split a string up using regular expressions. The problem is i suck at regular expressions which is making this even harder. What im trying to do is split something up that looks like some stuff here anything can be in here some stuff here i want to be able to pull down all the data inside the and part, the thing is there can be more then one part inside the text so for example some text anything can be in here some more text anything can be in here should give me both the code sections in an array, i was trying to use preg_split() to do this but i cant seem to get the correct regular expression. ---Edit--- Never mind i ended up working it out, there is a preg_match_all function in php which will place all the results inside an array, just in case anyone was wondering how i done it here is the code function getCode($str) { $codeI = preg_match_all('/[code](.*?) /is', $str, $code); for($i =0; $i <sizeof($code); $i++) { for($x =0; $x <sizeof($code[$i]); $x++) { echo $code[$i][$x] ."<br>"; } }}[/code] Quote
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.