OK, I have an answer to my question, but I was wondering if there was a quicker way than my solution...

my example uses only 2 dimensions for simplicity:

$array=array(
	0 => array("class"=>"11.104", "img_format"=>"jpg"),
	1 => array("class"=>"13.2", "img_format"=>"gif"),
	2 => array("class"=>"8.215", "img_format"=>"png")
);

what I want to do is implode ONLY the values of the 'class' key.

My solution at the moment is to put the values of that key into a single dimension array and implode() that:

foreach($array as $v1) {
    foreach ($v1 as $key => $value) {
    	if($key=='class') $class_array[]=$value;
	}
}
$class=implode(", ", $class_array);
echo $class;

Is there an easier way, because my code at the moment to do that with the actual array is rather large!

    No need for a separate array and implode. Just concatenate them together (note that this will leave an extra comma at the end of the string, you can trim that off after the loop):

    $class = '';
    foreach($array as $v1) {
        $class .= $v1["class"] . "," ;
    }
    
      Write a Reply...