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";
}
?> 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/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

<*> 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