mkosmosports Posted October 23, 2007 Share Posted October 23, 2007 Hey, I tried imploding a column in my MD array like so: implode(" AND ", $mainarr['br']['sumconditions']) but this doesnt work returning a bad arguments error message. Does anyone know how to do this? Thanks. Marek Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/ Share on other sites More sharing options...
BlueSkyIS Posted October 23, 2007 Share Posted October 23, 2007 is $mainarr['br']['sumconditions'] an array? can you give us the exact error, including line number, and maybe post more code? Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376539 Share on other sites More sharing options...
Barand Posted October 23, 2007 Share Posted October 23, 2007 Unfortunately, ability to implode array is no substitute for clairvoyance. What does your $mainarr look like? Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376543 Share on other sites More sharing options...
mkosmosports Posted October 23, 2007 Author Share Posted October 23, 2007 My apologies. Yes, $mainarr['br']['sumconditions'] is an array and below is the $mainarr array $mainarr = array("boundvalues"=>array(), "br"=>array("sumconditions"=>array(), "resultconditions"=>array()), "pd"=>array("sumconditions"=>array(),"resultconditions"=>array())); Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376559 Share on other sites More sharing options...
Barand Posted October 23, 2007 Share Posted October 23, 2007 running this code gives no output (as the array is empty) but there is no error message. <?php error_reporting(E_ALL); $mainarr = array( "boundvalues" => array(), "br" => array( "sumconditions" => array(), "resultconditions" => array() ), "pd" => array( "sumconditions" => array(), "resultconditions" => array() ) ); echo implode(" AND ", $mainarr['br']['sumconditions']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376565 Share on other sites More sharing options...
Barand Posted October 23, 2007 Share Posted October 23, 2007 adding values "sumconditions" => array(1,2,3), --> 1 AND 2 AND 3 as expected Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376569 Share on other sites More sharing options...
mkosmosports Posted October 23, 2007 Author Share Posted October 23, 2007 Thanks Barand. I have figured out whats wrong, but I made the mistake of assuming multidimensional sub-arrays dont implode.... ??? Sorry. Somewhere in my script I assigned a string to $mainarr['br']['sumconditions'] as opposed to assigning the string to $mainarr['br']['sumconditions'][], so I was in effect no longer imploding an array. Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376577 Share on other sites More sharing options...
roopurt18 Posted October 23, 2007 Share Posted October 23, 2007 I hate when I do that. Quote Link to comment https://forums.phpfreaks.com/topic/74506-solved-implode-multidimensional-array-column/#findComment-376584 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.