note 92789 added to function.array-keys

From: Date: Sun, 09 Aug 2009 09:49:25 +0000
Subject: note 92789 added to function.array-keys
Groups: php.notes 
Request: Send a blank email to php-notes+get-159228@lists.php.net to get a copy of this message
A quick example to display "the number of occurences" of a value in an array by using array_keys() can be. <?php echo count(array_keys($targetArray,"searchValue"); ?> e.g <?php $sites = array("google.com","haroonahmad.co.uk","google.com"); echo "Google occurs " . count(array_keys($sites,"google.com")) . " times in sites"; ?> I hope it helps, Haroon Ahmad ---- Server IP: 92.48.74.199 Probable Submitter: 94.194.11.237 ---- Manual Page -- http://www.php.net/manual/en/function.array-keys.php Edit -- https://master.php.net/note/edit/92789 Del: integrated -- https://master.php.net/note/delete/92789/integrated Del: useless -- https://master.php.net/note/delete/92789/useless Del: bad code -- https://master.php.net/note/delete/92789/bad+code Del: spam -- https://master.php.net/note/delete/92789/spam Del: non-english -- https://master.php.net/note/delete/92789/non-english Del: in docs -- https://master.php.net/note/delete/92789/in+docs Del: other reasons-- https://master.php.net/note/delete/92789 Reject -- https://master.php.net/note/reject/92789 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159228) next »