PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $relatie_id = 4; $data['players'] = [ ['member_id' => 1], ['member_id' => 2], ['member_id' => 3], ]; $start = microtime(true); for ($i = 1; $i <= 1000000; $i++) { $found = array_reduce($data['players'], function (bool $carry, array $item) use($relatie_id) { return $carry || $item['member_id'] == $relatie_id; }, false); } var_dump(microtime(true) - $start); $start = microtime(true); for ($i = 1; $i <= 1000000; $i++) { $found = array_search($relatie_id, array_column($data['players'], 'member_id')) > 0; } var_dump(microtime(true) - $start);
Show:  
Copy Clear