slj90 Posted May 24, 2014 Share Posted May 24, 2014 For example if $names has a value of "Mark/Ben/James/Tom" how would I separate it to give each name its own variable, e.g $name1, $name2, $name3 Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/288735-separate-variable/ Share on other sites More sharing options...
Jacques1 Posted May 24, 2014 Share Posted May 24, 2014 Numbering variables is a bad idea. Just make an array: <?php $name_list = "Mark/Ben/James/Tom"; $names = explode('/', $name_list); echo 'The first name is: ' . $names[0]; Quote Link to comment https://forums.phpfreaks.com/topic/288735-separate-variable/#findComment-1480703 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.