0

I have a this:

$output = print_r($feedDrive, true);

But I just want the actual values, not the commas, or [0] => etc.

How can I do this?

3
  • one option: implode ( ' ' , $feedDrive ); that would make the values space separated Commented Sep 16, 2017 at 3:31
  • print_r() is a function used for debug. Use implode(', ', $feedDrive)](php.net/manual/en/function.print-r.php) to generate a string that contains the values separated by comma and echo to display it. Or use a foreach loop to iterate over the array and process its (keys and) values in any way to want. Commented Sep 16, 2017 at 17:50
  • Don't understand why when I posted rtfms answer it was downvoted. Commented Sep 17, 2017 at 20:23

1 Answer 1

1

There is foreach loop in php. You have to traverse the array.

foreach($array as $key => $value)
{
  echo $value;
}

If you simply want to add commas between values, consider using implode

$string=implode(",",$array);
echo $string;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.