rockinaway Posted September 7, 2007 Share Posted September 7, 2007 I want to enter several numbers that are member ids in my function... which is $func->id() Now I want to add several.. so how can I add them without encountering an error, as a list.. e.g something like id(4:5:6:7) If I do that I get an error, that the : was unexpected.. I use a split in my function to seperate the numbers.. so what could be the problem? Link to comment https://forums.phpfreaks.com/topic/68386-splitting-values/ Share on other sites More sharing options...
pocobueno1388 Posted September 7, 2007 Share Posted September 7, 2007 Well, you can accept an array of ID's for the function parameter. <?php function id ($id_array){ //function stuff here } ?> Then inside your function you can loop through the array... Link to comment https://forums.phpfreaks.com/topic/68386-splitting-values/#findComment-343834 Share on other sites More sharing options...
corbin Posted September 7, 2007 Share Posted September 7, 2007 function EchoEach($array) { foreach($array as $v) echo $v; } EchoEach(array(1,2,3,4,5)); //echos 12345 To elaborate on pocobueno's post ;p Link to comment https://forums.phpfreaks.com/topic/68386-splitting-values/#findComment-344015 Share on other sites More sharing options...
rockinaway Posted September 8, 2007 Author Share Posted September 8, 2007 Thanks Link to comment https://forums.phpfreaks.com/topic/68386-splitting-values/#findComment-344192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.