This is my first post, and I'm fairly new at php, so please be gentle.
I'm trying to find out how to make an array from an array of keys and an array of values. The array of values is returned from the explode function, so has numeric keys, but I want these to be named/associative. I feel that there should be a function for this, but can only do it with a messy for loop.
Code: Select all
$fieldnames = array('Name1','Name2','NameEtc');
$fieldvalues = explode(',', $sometext);
# this is the bit I want a function for, like:
# $line = somefunction($fieldnames,$fieldvalues);
# but instead, I have to do this:
for ($j=0; $j < count($fieldnames); $j++) {
$line[$fieldnames[$j]] = $fieldvalues[$j];
}
php seems so concise and neat, I find it hard to believe this function doesn't exist
I hope this makes sense.
Bernie