Michiel
11-22-2003, 08:15 PM
Hi,
I've got a question about selecting data from an array. I've got an array with the following format:
$db[0]['name'] = 'john'
$db[0]['age'] = 18
$db[0]['gender'] = 'm'
$db[1]['name'] = 'janet'
$db[1]['age'] = 17
$db[1]['gender'] = 'f'
etc.
I want to select the array keys of the items that match a condition that is constructed as 'gender = m' or 'age > 10'. I want to write a function that can return an array that contains all the keys of the array $db that match the condition.
E.g. if the condition 'gender = m' is used the function should return: $return = array(0)
And if the condition is 'age > 10' the function should return $return = array(0,1)
How would I go about that? What functions should I examine further? Can anyone push me in the right direction?
I hope I've been clear enough ... if not please let me know and I'll elaborate. Thanx in advance for your replies!
Cheers, Michiel
I've got a question about selecting data from an array. I've got an array with the following format:
$db[0]['name'] = 'john'
$db[0]['age'] = 18
$db[0]['gender'] = 'm'
$db[1]['name'] = 'janet'
$db[1]['age'] = 17
$db[1]['gender'] = 'f'
etc.
I want to select the array keys of the items that match a condition that is constructed as 'gender = m' or 'age > 10'. I want to write a function that can return an array that contains all the keys of the array $db that match the condition.
E.g. if the condition 'gender = m' is used the function should return: $return = array(0)
And if the condition is 'age > 10' the function should return $return = array(0,1)
How would I go about that? What functions should I examine further? Can anyone push me in the right direction?
I hope I've been clear enough ... if not please let me know and I'll elaborate. Thanx in advance for your replies!
Cheers, Michiel