Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php $data[] = array("id" => "1", "content" => "Hello", "content1" => "Hello"); $data[] = array("id" => "2", "content" => "World", "content1" => "Hello1"); $data[] = array("id" => "3", "content" => "World", "content1" => "Hello1"); // filter the data $data = array_filter($data, function($value) { if ($value['content'] == "World" && $value['content1'] == "Hello1") { return $value['content']; } }); // map the data //$data = array_map(fn ($value) => ['content' => $value['content'], 'content1' => $value['content1']], $data); // reset indexes $data = array_values($data); print_r($data[0]);
Copy Clear