kts Posted April 3, 2008 Share Posted April 3, 2008 I have a variable that contains ## or ##_## or ##_##_## I would like to use regex i believe? to grab out if its ##_## grab both nums and define which is first and second as well as the third ##_##_## 1, 2, 3 in seperate variables or an array is this possible? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 3, 2008 Share Posted April 3, 2008 <?php $numbers = "##_##_##"; $number = explode('_', $numbers); echo '<pre>',print_r($number),'</pre>'; ?> The first number will be stored in $number[0], second number $number[1], etc. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 3, 2008 Share Posted April 3, 2008 $numbers = explode("_", $variable); print_r($numbers); $numbers[0] = your first number; $numbers[1] = your second number; Quote Link to comment Share on other sites More sharing options...
kts Posted April 3, 2008 Author Share Posted April 3, 2008 Thank you thank you.. very much appreciated 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.