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? Link to comment https://forums.phpfreaks.com/topic/99431-trying-to-cut-up-a-string/ 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. Link to comment https://forums.phpfreaks.com/topic/99431-trying-to-cut-up-a-string/#findComment-508769 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; Link to comment https://forums.phpfreaks.com/topic/99431-trying-to-cut-up-a-string/#findComment-508770 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 Link to comment https://forums.phpfreaks.com/topic/99431-trying-to-cut-up-a-string/#findComment-508776 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.