note 119412 deleted from language.types.array by peehaa

From: Date: Sun, 28 Apr 2019 10:23:45 +0000
Subject: note 119412 deleted from language.types.array by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-210773@lists.php.net to get a copy of this message
Note Submitter: php at markuszeller dot com ---- Sometimes I need to match fieldnames from database tables. But if a source field is used many times you can not use a hash "=>", because it overrides the key. My approach is to use a comma separated array and use a while-loop in conjunction with each. Having that you can iterate key/value based, but may have a key multiple times. $fieldmap = array ( 'id', 'import_id', 'productname', 'title', 'datetime_online', 'onlineDate', 'datetime_test_final', 'offlineDate', 'active', 'status', 'questionaire_intro', 'text_lead', 'datetime_online', 'createdAt', 'datetime_online', 'updatedAt' ); while(list(,$key) = each($fieldmap)) { list(,$value) = each($fieldmap); echo "$key: $value\n"; }

« previous php.notes (#210773) next »