mardi 26 mars 2019

How to remove an array from a Multidimensional array by key if condition is met Php

I have a array structured like so

array:2 [▼
  "id_1553623907416" => array:2 [▼
    "id_title" => "About"
    "id_content" => """
      <!DOCTYPE html>
      <html>
      <head>
      </head>
      <body>
      <p>Helllo world</p>
      </body>
      </html>
      """
  ]
  "id_1553623916174" => array:2 [▼
    "id_title" => "Education"
    "id_content" => """
      <!DOCTYPE html>
      <html>
      <head>
      </head>
      <body>
      <p>hello data</p>
      </body>
      </html>
      """
  ]
]

i need to be able to remove the array named id_1553623907416 if it contains the value About in the sub-array key id_title. The ids are dynamic so this has to be dynamically.

that array is stored in the variable @output.

 @foreach ($output as $item)    
   @if($item["id_title"] == "About")
      //remove array 
   @else
     //do something else 
   @endif
@endforeach



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2I0KEsX
via IFTTT

Aucun commentaire:

Enregistrer un commentaire