i have this $_categories as array()
<?php print_r($_categories); ?>
is this: Array ( [0] => 13 [1] => 7 )
what i need is to extract de values 13 and 7 into this format: 13,7 (without comma after the last value).
i have this code but is not there yet... the result is: 137 and not 13,7
<?php
if ( is_array($_categories) ) {
foreach ($_categories as $key => $value) {
$out = array();
array_push($out, $value);
echo implode(', ', $out);
}
}
else {
echo '<li>There are no saved values yet.</li>';
}
?>
Thanks, nelson
Directly use
Everytime you are
implode
ing just one element,andecho
ing just it. Try like this: