-2
Array
(
[0] => stdClass Object
    (
        [features_id] => 2
        [features_type] => TV
    )

[1] => stdClass Object
    (
        [features_id] => 5
        [features_type] => New balls
    )

[2] => stdClass Object
    (
        [features_id] => 6
        [features_type] => Basketball pitch
    )
)

For get result of my array i want to display this record separated by comma like:

 New balls,Basketball pitch.

By using foreach how to write don't know how get this type result

Harsh Barach
  • 947
  • 9
  • 18
Vyas Jay
  • 1
  • 3

2 Answers2

3

You can achieve your output without using foreach loop. Please try below code.

$singlArray = array_column($multiDimArray, 'features_type') // this convert multiple dimension array to single array
$finalValue= implode(',',$singlArray);
sunilwananje
  • 714
  • 5
  • 17
0

The solution is fairly simple:

foreach($array as $item){
    echo $item->features_type.',';
}
Jan Rydrych
  • 2,188
  • 2
  • 13
  • 18