so basically i created this array to convert an indexed array into a assoc array.
say this is my input array
$input = array('this is the title','this is the author','this is the location','this is the quote');
and this is my function
function dynamicAssocArray($input)
{
$result = array();
$assocArrayItems = array('title', 'author', 'location', 'quote');
$assocItem;
foreach ($input as $value)
{
for ($i=0; $i <= 3; $i++)
{
$assocItem = $assocArrayItems[$i];
}
$result = $result[$assocItem] = $value;
}
return $result;
}
im getting this error “Warning: Illegal string offset ‘quote'” and the output is string(1) “t”
which i totally do not understand, so any help would be greatly appreciated.
try this
output