Miko Posted July 7, 2009 Share Posted July 7, 2009 Hello, I'm trying to 'split' a value in 2. example: $var = '012345678910234' I would like to split this after the fourth value, meaning after the '3'. So afterworth I should have '0123' & '45678910234' Anyone know how to do that? Thanks! Link to comment https://forums.phpfreaks.com/topic/165059-split-value/ Share on other sites More sharing options...
Mark Baker Posted July 7, 2009 Share Posted July 7, 2009 $var = '012345678910234'; $var1 = substr($var,0,4); $var2 = substr($var,4); Link to comment https://forums.phpfreaks.com/topic/165059-split-value/#findComment-870390 Share on other sites More sharing options...
exhaler Posted July 7, 2009 Share Posted July 7, 2009 u can use substr() function; <?php echo substr ($var, 0 ,4); ?> first parameter is for the word ur splitting, the second is the index to start from, the third is the index to stop at go here for more info http://www.php.net/manual/en/function.substr.php Link to comment https://forums.phpfreaks.com/topic/165059-split-value/#findComment-870392 Share on other sites More sharing options...
Miko Posted July 7, 2009 Author Share Posted July 7, 2009 great thanks, I'll try this out Link to comment https://forums.phpfreaks.com/topic/165059-split-value/#findComment-870395 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.