3v4l.org

run code in 500+ PHP versions simultaneously
<?php $accountdata = array( array("name" => "test1", "email" => "test1@test.com"), array("name" => "test2", "email" => "test2@test.com"), array("name" => "test3", "email" => "test3@test.com"), array("name" => "test4", "email" => "test4@test.com"), ); foreach ($accountdata as $row) { $data[$row["email"]] = [ 'name' => $row["name"], 'email' => $row["email"] ]; } echo json_encode($data, JSON_UNESCAPED_UNICODE);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.7
{"test1@test.com":{"name":"test1","email":"test1@test.com"},"test2@test.com":{"name":"test2","email":"test2@test.com"},"test3@test.com":{"name":"test3","email":"test3@test.com"},"test4@test.com":{"name":"test4","email":"test4@test.com"}}

preferences:
95.54 ms | 1153 KiB | 4 Q