kev wood Posted May 30, 2008 Share Posted May 30, 2008 i want to know if the limit on the explode can be defined by a variable. the code is normally written out in this way $exploded_friends = explode(' ', $friends, 3); what i want to know if it can be written out like this $exploded_friends = explode(' ', $friends, $limit); with $limit being set before the explode function has been executed. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/ Share on other sites More sharing options...
GingerRobot Posted May 30, 2008 Share Posted May 30, 2008 Of course. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553409 Share on other sites More sharing options...
kev wood Posted May 30, 2008 Author Share Posted May 30, 2008 thanks for the reply i could not find a tutorial anywhere were the number was set in this way, i thought it is best checking befroe i begin coding. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553421 Share on other sites More sharing options...
kev wood Posted May 30, 2008 Author Share Posted May 30, 2008 i have just been looking at the examples again and some have the number inside [] and others do not which is the correct way to write this out. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553428 Share on other sites More sharing options...
Daniel0 Posted May 30, 2008 Share Posted May 30, 2008 Keep in mind that the variable is just a container holding a value Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553432 Share on other sites More sharing options...
.josh Posted May 30, 2008 Share Posted May 30, 2008 without the [] you would put a number or variable there just like any other argument. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553434 Share on other sites More sharing options...
kev wood Posted May 30, 2008 Author Share Posted May 30, 2008 sound nice one for that. i was just unsure as some of the examples had them in with a number and some had them without and the number still there. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553436 Share on other sites More sharing options...
GingerRobot Posted May 30, 2008 Share Posted May 30, 2008 Are you referring to the square brackets like are shown here? array explode ( string $delimiter , string $string [, int $limit ] ) If so, it's just the way that it is shown that a parameter is optional. Quote Link to comment https://forums.phpfreaks.com/topic/107978-solved-explode-with-limit/#findComment-553440 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.