PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $filters = array("cata" => ['culo', 'moco'], "catb" => ['pura','falopa'], "catc" => [], "catd" => []); // filter the data //$data = array_filter($data, fn ($value) => $value['content'] === 'World'); // map the data //$data = array_map(fn ($value) => ['content' => $value['content']], $data); // reset indexes //$data = array_values($data); function getString($arr): string { return "SAD(" . implode( ", ", array_map( function($key) use ($arr){ if(isset($arr[$key]) && !empty($arr[$key])) { return $key . ", " . innerMap($arr[$key]); } }, array_keys($arr)) ); } function innerMap(array $arr): string { return implode(",", array_map(fn($e) => '\"' . $e . '\"', $arr)); } $datala = array_filter($filters, fn($e) => !empty($e)); print_r($datala); echo getString($datala);
Show:  
Copy Clear