CascadiaPHP 2024

Voting

: max(one, nine)?
(Example: nine)

The Note You're Voting On

thomas dot sahlin at gmail dot com
14 years ago
If you're creating an array yourself and then using in_array to search it, consider setting the keys of the array and using isset instead since it's much faster.

<?php

$slow
= array('apple', 'banana', 'orange');

if (
in_array('banana', $slow))
print(
'Found it!');

$fast = array('apple' => 'apple', 'banana' => 'banana', 'orange' => 'orange');

if (isset(
$fast['banana']))
print(
'Found it!');

?>

<< Back to user notes page

To Top -