the_oliver Posted January 6, 2007 Share Posted January 6, 2007 Having a blank moment hear!I have a list of variables ($c1, $c2, $c3 etc ... ) and want the to run one by one throught a function. function($c1) followed by function($c2) etc. How do i do this?Thanks Link to comment https://forums.phpfreaks.com/topic/33097-solved-for-statment/ Share on other sites More sharing options...
psychohagis Posted January 6, 2007 Share Posted January 6, 2007 you should put the variables in an array Link to comment https://forums.phpfreaks.com/topic/33097-solved-for-statment/#findComment-154210 Share on other sites More sharing options...
the_oliver Posted January 6, 2007 Author Share Posted January 6, 2007 go on..... Link to comment https://forums.phpfreaks.com/topic/33097-solved-for-statment/#findComment-154211 Share on other sites More sharing options...
psychohagis Posted January 6, 2007 Share Posted January 6, 2007 mm well look it up. Sorry, i cant help more, i know should put them in an array but i dont know how to do that Link to comment https://forums.phpfreaks.com/topic/33097-solved-for-statment/#findComment-154215 Share on other sites More sharing options...
wildteen88 Posted January 6, 2007 Share Posted January 6, 2007 You are best of setting up an array. You do it like so:$c[] = 'some value';$c[] = 'some other value';$c[] = 'what ever else']That will create an array. remeber everytime you do $c[]= you create new item for the array.When you've created the array you can run through the array using a foreach loop like so:[code=php:0]foreach($c as $value){ // call your function urFunc($value);}[/code]Or you can use [url=http://www.php.net/manual/en/function.array-map.php]array_map[/url] which does the same thing as the foreach loop above Link to comment https://forums.phpfreaks.com/topic/33097-solved-for-statment/#findComment-154264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.