mardi 20 octobre 2020

in laravel collection remove key if value is null

i new in laravel, trying to filter null value array and remove from array. like this i have this array from response

array:8 [▼
  "videoa" => Collection {#801 ▼
    #items: []
  }
  "music" => Collection {#872 ▼
    #items: array:69 [▶]
  }
  "meditation" => Collection {#869 ▼
    #items: array:1 [▶]
  }
]

see , in this array videos has null , but i want following array

array:8 [▼
 
  "music" => Collection {#872 ▼
    #items: array:69 [▶]
  }
  "meditation" => Collection {#869 ▼
    #items: array:1 [▶]
  }
  
]

when the key value is null then remove it from array. i tried array_filter($array); but not get any results. plase help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire