Whenever I seek to show the contents of an array based on data from an SQL database, the output always is prefixed with the word "Array". It doesn't matter whether I use echo, print_r(), var_dump() or otherwise. Code below. Any ideas greatly received!
$prefix1 = '';
$tasks = array($product, $service, $order, $social, $competition, $dataOther);
foreach ($tasks as $task) {
if ($task == '') {
unset($task);
} else {
$tasks .= $prefix1 . '' . $task . '';
$prefix1 = ', ';
}
}
echo $tasks;
Output - "Array" followed by the contents of $tasks
Edit: I cannot use implode(', ', $tasks)
because each of the inputs (i.e. $product
, $service
etc.) could be blank and therefore the outcome would be ",," in places.
Hope that's clearer.