> i have an array like:
>
> Array
> (
>     [1] => Array
>         (
>             [alias] => foo
>             ...
>         )
>     [2] => Array
>         (
>             [alias] => bar
>             ...
>         )
>     ...
> )
>
> I need some way to find out, if an alias "foo" is in the array. Any idea how
> to do this?

Assuming your outer array is called $array_of_arrays:

<?php
$found = 0;
foreach ($array_of_arrays as $array) {
  if ($array['alias'] == 'foo') {
    $found = 1;
    break;
  }
}
if ($found) {
  // you found it!
}
else {
  // too bad!
}
?>

Or, you can look at this:

  http://www.php.net/manual/en/function.in-array.php

if you're not sure what key 'foo' will be at, or this:

  http://www.php.net/manual/en/function.array-search.php

if you're not sure what key 'foo' will be at and you want to know what
that key is.

Joel

-- 
[ joel boonstra | [EMAIL PROTECTED] ]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to