note 119412 added to language.types.array
| From: | php at markuszeller dot com | Date: | Wed, 01 Jun 2016 09:24:11 +0000 |
| Subject: | note 119412 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205628@lists.php.net to get a copy of this message | ||
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";
}
----
Server IP: 72.52.91.14
Probable Submitter: 188.109.64.95
----
Manual Page -- http://php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/119412
Del: integrated -- https://master.php.net/note/delete/119412/integrated
Del: useless -- https://master.php.net/note/delete/119412/useless
Del: bad code -- https://master.php.net/note/delete/119412/bad+code
Del: spam -- https://master.php.net/note/delete/119412/spam
Del: non-english -- https://master.php.net/note/delete/119412/non-english
Del: in docs -- https://master.php.net/note/delete/119412/in+docs
Del: other reasons-- https://master.php.net/note/delete/119412
Reject -- https://master.php.net/note/reject/119412
Search -- https://master.php.net/manage/user-notes.php