07052006 1400 GMT-6

Of course, as soon as I ask I find the answer:

foreach($search_terms as $search_item){
        if(array_key_exists($search_item, $search_array)){
                if(!empty($search_array[$search_item])){
                        $data[$search_item] = $search_array[$search_item];
                }       
        }
}



On Wed, 2006-07-05 at 13:45 -0500, Wade Smart wrote:
> 07052006 1340 GMT-6
> 
> This is a little test that I was playing with but Im not doing so well
> with it. 
> 
> It takes an array, usually Post, and goes through looking for array keys
> with a set of predefined keys in a second array. If the key is present
> it looks to see if its empty. If it is not then its added to an array
> for later use. Right now its only seeing one key - fname with 'Bob'.
> 
> <?php
> $data = array();
> $item = array();
> $search_array = array('fname' => 'Bob', 'lname' => 'Smith', 'phone', 
> 'address' => '123 This Road toKnowWhere', 'city' => 'Batesville', 'state' => 
> 'IO', 'zip' => '00021', 'register' => 'Register', '0' => 'Array');
> $search_terms = array('fname', 'lname', 'phone', 'address', 'city', 'state', 
> 'zip');
> 
> foreach($search_terms as $search_item => $value){ 
> 
>       if (array_key_exists($search_item, $search_array)){
>        
>               if(!empty($search_array[$search_item])){
>               
>                       $data[$search_item] = $search_array[$value];
>               
>               }
>       }
> }
> 
> foreach($data as $key => $val){
>       print "<br /> $key : $val";
> }
> ?> 
> 
> 
> 
> 
> 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/
 



Reply via email to