<?php $array = [ 'ip' => '127.0.0.1', 'user_agent' => 'dkdkdk', '_id' => 'fjjfjf', 'user' => [ 'longName' => '', 'shortName' => '', 'username' => [ 'a' => 'b', 'c' => '' ] ], 'dsd' => [ 'zz' => [ 'dd' => [ 'ff' => '' ] ] ], 'dsddd' => '', 'vcv' => null, 'aavx' => 0 ]; function removeEmptyArrays(&$array){ foreach($array as $key => &$value){ if(is_array($value)) removeEmptyArrays($value); if(is_array($value) && count($value) == 0 || is_null($value) || is_string($value) && strlen($value) == 0) unset($array[$key]); } } removeEmptyArrays($array); print_r($array);
You have javascript disabled. You will not be able to edit any code.