sutho100
8/14/2019 - 5:06 AM

php filter compare array and remove empty


                                                        $week = [
                                                        'sunday'=>[],
                                                        'monday'=>[],
                                                        'tuesday'=>[],
                                                        'wednesday'=>[],
                                                        'thursday'=>[],
                                                        'friday'=>[],
                                                        'saturday'=>[],
                                                        ];
                                                        $dayValue =  $itemdata['attributes']['openingHours'];
                                                        foreach($dayValue as $key=>$value) {
                                                            $week[$key]=$value;
                                                        }
                                                        $weeks= array_filter($week,function($item){
                                                                return count($item)>0;
                                                        });
                                                        // dd($dayValue);
                                                        dd($weeks);
                                                $sortingArr = $week;
                                                $result = array(); // result array