1bigbear Posted November 3, 2009 Share Posted November 3, 2009 Hi, I have a foreach $verify="a"; foreach ($value as $each) if ($each == $verify) { function strange( $text) { // do something } }} the error: Fatal error: Cannot redeclare strange But I have to use the strange function on each iteration of the array. How to solve this problem? Quote Link to comment Share on other sites More sharing options...
Mchl Posted November 3, 2009 Share Posted November 3, 2009 Declare it before loop. Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted November 3, 2009 Share Posted November 3, 2009 you could declare strange at the begining of your php page then return a value. Then just call it in your loop. // this is the beginning of your page function strange($text) { // do something return $something; } then in your loop foreach($value as $each) { if($each==$verify) { $something=strange($text); } } Quote Link to comment Share on other sites More sharing options...
1bigbear Posted November 3, 2009 Author Share Posted November 3, 2009 Your right thanks Quote Link to comment 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.