fork download
  1. <?php
  2.  
  3. $array = [
  4. [
  5. 'name' => 'Blackberry Kush',
  6. 'qty' => '1'
  7. ],
  8. [
  9. 'name' => 'Granddaddy Purple',
  10. 'qty' => '1'
  11. ],
  12. [
  13. 'name' => '20% THC',
  14. 'qty' => '1'
  15. ],
  16. [
  17. 'name' => 'Pomegranate Blue-Rasp',
  18. 'qty' => '1'
  19. ],
  20. [
  21. 'name' => 'Blueberry Vanilla',
  22. 'qty' => '2'
  23. ],
  24. [
  25. 'name' => 'Banana Strawberry',
  26. 'qty' => '3'
  27. ]
  28. ];
  29.  
  30. $formatted = array_map( function($obj) {
  31. return "{$obj['name']} {$obj['qty']}";
  32. }, $array );
  33.  
  34. echo implode( ', ', $formatted );
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
Blackberry Kush 1, Granddaddy Purple 1, 20% THC 1, Pomegranate Blue-Rasp 1, Blueberry Vanilla 2, Banana Strawberry 3