[UPHPU] interesting array issue

TJ Hunter tjhunter at ruistech.com
Fri May 21 13:46:16 MDT 2004


I usually try to avoid this problem while creating the array. This may 
or may not work for your particular problem, but I try to create an 
array with the following structure:

$array[$id] = array(of some other info);
then you can check to see if $id already exists in that array before you 
add another one.

in the case you WANT to be able to handle multiple IDs of things, do this:

$id = 1;
$array[$id][0] = array(of some other info);
$array[$id][1] = array(of some other info);
$id = 2;
$array[$id][0] = array(of some other info);
$array[$id][1] = array(of some other info);
...

anyway, don't know if this is applicable in your case, but hope it helps.
-TJ

Steve Dibb wrote:

>I have a weird count I want to do, in order to avoid yet another mysql query ....
>
>I have an array, similar to something like this:
>
>$array[0]['id']=5;
>$array[1]['id']=5;
>$array[2]['id']=7;
>$array[3]['id']=7;
>$array[4]['id']=7;
>$array[5]['id']=8;
>$array[6]['id']=9;
>
>
>Where the ['id'] value can show up more than once ... what I want to do is know if it is showing up more than
>once, though.
>
>So basically I want to know if $array[$x]['id'] has the same value more than once -- an example would be
>there's many that have the value of 7, and that's what I need to find out.
>
>Is there anyway to do that without hopefully looping through the entire array?
>
>Steve
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: list-unsubscribe at uphpu.org
>For additional commands, e-mail: list-help at uphpu.org
>
>
>
>
>  
>




More information about the UPHPU mailing list