I have an API that I need to write to that expects
$foo = array(
'tags[]' => array('one','two','three','four')
);
My array looks like this
Array
(
[0] => one
[1] => two
[2] => three
[3] => four
[4] => five
[5] => six
)
I've tried adding the array
$foo = array(
'tags[]' => array($arr)
);
But this prints 'Array' once in the database. How do I add the values from $arr to the tags[]?
Your tags[]
array is one level too deep. It should be:
$foo = array(
'tags[]' => $arr
);
Note how $arr
is not wrapped in array()
.
If you don't remove the array()
then it looks like:
$foo = array(
'tags[]' => array(
array('one', 'two', 'three')
)
);