-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

0

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

Comments

0

The solution is fairly simple:

foreach($array as $item){
    echo $item->features_type.',';
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.