You are here: How to avoid in_array() function. « PHP Programming Language « IT news, forums, messages
How to avoid in_array() function.

Posted by Berimor on 12/04/05 17:34

Hi,
i've been always used the in_array() function to check availabylity of a
value in array. Until today. Simple code: (do not run it tho :) )

<?
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}

$time_start = getmicrotime();

$first=range("a","z");
$second=range("a","z");
$third=range("a","z");
$all_arr=array();

foreach ($first as $f){
foreach ($second as $s){
foreach ($third as $t){

$ind=$f.$s.$t;
if (!in_array($ind,$all_arr)) $all_arr[]=$ind;


}
}
}


$time_end = getmicrotime();
$time = $time_end - $time_start;
echo $time;
?>

It prints the time script worked. Guess the number?
250(!!!!) seconds!!!
Is there any alternative in PHP to check array?




--
Exact Meta Search | Major Search Engine http://exactsearcher.com
Web Design Essex | Multimedia | Printing http://nextwave.co.uk

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация