How can I in an API echo results in a new array?
example:
echo implode('[]',$resultArray);
result:
$resultArray
requested result:
[$resultArray]
Since you're implementing an API the best pracrice will be to output your results in a format that's readable and understandable by multiple programming languages. JSON is the way to go. Read about it here and here
To echo an array, or anything not just an array, in PHP in a JSON format use:
echo json_encode($data);
where $data holds the output
echo json_encode($resultArray);
Assuming you want to keep the data in the response an array to the requester.
If not, your example will work but I'd suggest something easy to parse on the requester's side like a CSV value using commas: echo implode(',', $resultArray);
if you're looking to output the string '[$resultArray]', it'll be something like echo '[$'.print_var_name($resultArray).']'. Not sure why you'd need it like this, but your question is a little bit vague/confusing on exactly what you're looking for.
json_encode?var_dump or print_ris it in php side?