So, I'm working with PHP for the first time and I am trying to retrieve and display the values of an array. After a lot of googling, the only methods I can find for this are print_r
, var_dump
or var_export
. However, all of these methods return something that looks like this:
[a] => apple
[b] => banana
[c] => orange
I can't figure out how to style this outout. I need to strip away the [a] =>
part and add commas. I know this must be a pretty straightforward process but I haven't been able to track down any documentation that demonstrates how to do it.
Iterate over the array and do whatever you want with the individual values.
You can use implode to return your array with a string separator.
you can easily use join()
Result:
Array
(
[a] => apple
[b] => banana
[c] => orange
)
a simple code snippet that i prepared, hope it will be usefull for you;
the
join()
function must work for you:Output :