Hi,
To search an array for anything that match another array I'm doing this:
$array1 = array(array()); //I put value in here not shown
$array2 = array(array()); //I put value in here not shown
$position1 = 0;
foreach ( $array1 as $value ){
$position2 = 0;
foreach($array2 as $value2 ){
if ( $array1[$position1]['id'] == $array2[$position2]['id']){
$array1[$position2]['answer'] =
$array2[$position2]['answer'];
$array1[$position2]['remote_address'] =
$array2[$position2]
['remote_address'];
$$array1[$position2]['date_time'] =
$array2[$position2]['date_time'];
} //end ID match test
$position2++;
} //end pre loop
$position1++;
}// end array search
So this lets me search one array for any instance match in another.
Is there a better way to do this?
Now how to sort the results in $array1 by $array1[]['answer'] ??
Sincerely,
Mike
--
Mike Brandonisio * IT Planning & Support
Tech One Illustration * Database Applications
tel (630) 759-9283 * e-Commerce
[EMAIL PROTECTED] * www.techoneillustration.com
On Jun 20, 2006, at 7:38 AM, Mike Brandonisio wrote:
> Hi,
>
> I'm having trouble working with Multidimensional Arrays. Does anyone
> have any tutorials or links they might share on the topic. The
> challenges I'm having are sorting by a value in the 2nd array and
> searching for a value in the second array.
>
> Array
> (
> [0] => Array
> (
> [id] => 6
> [answer] => A
> [remote_address] => 24.15.143.7
> [date_time] => 2006-06-20 07:35:24
> [survey_id] => 1
> )
>
> [1] => Array
> (
> [id] => 4
> [answer] => B
> [remote_address] => 24.15.143.7
> [date_time] => 2006-06-20 07:35:24
> [survey_id] => 1
> )
> )
>
> I'm just not getting how the php example works with usort() or
> array_filter().
>
> Sincerely,
> Mike
> --
> Mike Brandonisio * IT Planning & Support
> Tech One Illustration * Database Applications
> tel (630) 759-9283 * e-Commerce
> [EMAIL PROTECTED] * www.techoneillustration.com
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------
> ~-->
> Great things are happening at Yahoo! Groups. See the new email
> design.
> http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/HKFolB/TM
> --------------------------------------------------------------------
> ~->
>
> Community email addresses:
> Post message: [email protected]
> Subscribe: [EMAIL PROTECTED]
> Unsubscribe: [EMAIL PROTECTED]
> List owner: [EMAIL PROTECTED]
>
> Shortcut URL to this page:
> http://groups.yahoo.com/group/php-list
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/