MadnessRed Posted March 7, 2009 Share Posted March 7, 2009 I am having a problem with the implode function. I am running the following code. if(strlen($target['messages']) == 0){ $target['messages'] = '0,0,0,0,0,0'; } $messages = explode(",",$target['messages']); $messages[$type] += 1; $target['messages'] = implode(",",$mesages); $target['messages'] is either an imploded array eg 1,2,4,3,5,2 or its null. $target is a row form the database. however I am getting the following error. implode() [function.implode]: Invalid arguments passed if I print_r($messages) this is what i get. Array ( [0] => 0 [1] => 0 [2] => 1 [3] => 0 [4] => 0 [5] => 0 ) Any help would be great. Thanks Link to comment https://forums.phpfreaks.com/topic/148355-solved-problem-with-implode-function-ivalid-arguments-passed/ Share on other sites More sharing options...
MasterACE14 Posted March 7, 2009 Share Posted March 7, 2009 you have a typo. implode(",",$mesages); should be implode(",",$messages); Regards ACE Link to comment https://forums.phpfreaks.com/topic/148355-solved-problem-with-implode-function-ivalid-arguments-passed/#findComment-778857 Share on other sites More sharing options...
MadnessRed Posted March 7, 2009 Author Share Posted March 7, 2009 you have a typo. implode(",",$mesages); should be implode(",",$messages); Regards ACE thanks Link to comment https://forums.phpfreaks.com/topic/148355-solved-problem-with-implode-function-ivalid-arguments-passed/#findComment-778860 Share on other sites More sharing options...
MasterACE14 Posted March 7, 2009 Share Posted March 7, 2009 no problem. Link to comment https://forums.phpfreaks.com/topic/148355-solved-problem-with-implode-function-ivalid-arguments-passed/#findComment-778861 Share on other sites More sharing options...
MadnessRed Posted March 7, 2009 Author Share Posted March 7, 2009 you have a typo. implode(",",$mesages); should be implode(",",$messages); Regards ACE thanks actually I am still getting the same error. //Set messages of this type to +1 if(strlen($target['messages']) == 0){ $target['messages'] = '0,0,0,0,0,0'; } $messages = explode(",",$target['messages']); $messages[$type] += 1; print_r($messages); $newmessages = implode(",",$messages); Outputs Array ( [0] => 0 [1] => 0 [2] => 1 [3] => 0 [4] => 0 [5] => 0 ) Gives error implode() [function.implode]: Invalid arguments passed Link to comment https://forums.phpfreaks.com/topic/148355-solved-problem-with-implode-function-ivalid-arguments-passed/#findComment-778863 Share on other sites More sharing options...
MadnessRed Posted March 7, 2009 Author Share Posted March 7, 2009 sorry it was the $target array that was wrong. problem solved Link to comment https://forums.phpfreaks.com/topic/148355-solved-problem-with-implode-function-ivalid-arguments-passed/#findComment-778886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.