-1

The title says it all. I want to delete the highlighted section in yellow as shown in picture below. And rest remain unchanged. What is the best way to do it? Is there a method that does't use foreach?

enter image description here

1

3 Answers 3

2

you can do this just with one foreach!

foreach ($data as $key => $subArr) {
    unset($subArr['id']);
    $data[$key] = $subArr;  
}
Sign up to request clarification or add additional context in comments.

Comments

2

You can use the following

$filteredArray = array_map(function($array) {
    unset($array['id']);
    return $array;
}, $dataArray);

Comments

1

Instead of doing foreach() loop on the array, You can go with array_search()

$results=array_search($unwantedValue,$array,true);
if($results !== false) {
  unset($array[$result]);   
}

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.