PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $data[] = array("id" => "1", "content" => "Hello"); $data[] = array("id" => "2", "content" => "World"); // 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); $a = [ ['id' => 1], ['id' => 2], ['id' => 3], ]; $b = [ ['id_a' => 1, 'name' => 'boy'], ['id_a' => 3, 'name' => 'deth'], ]; $related = array_filter($b, function($item) use ($a) { return $item['id_a'] === $a['id']; }); print_r($related);
Show:  
Copy Clear