PHP 5 Error with array_merge()
The error:
- warning: array_merge() [function.array-merge]: Argument 2 is not an array
The 411 (as take from PHP.net):
“The behavior of array_merge() was modified in PHP 5. Unlike PHP 4, array_merge() now only accepts parameters of type array. However, you can use typecasting to merge other types.”
Example:
The offending code -
- $tag = array_merge($arg1,$arg2);
The fixed code -
- $tag = array_merge($arg1,(array)$arg2);
The fix is simple, you cast the offending argument in to hell and wash your hands of it, ok maybe not. But you do cast it just as an array.
You place (array) before the argument that your error says is not an array. In my example you can see the error referred to “argument 2″, so I placed (array) before my second argument.
No all is good and no one gets cast to hell ![]()
June 1st, 2007 at 12:37 am
OMG thank you so much I was trying to figure out how to fix this for hours today. Thank you thank you thank you.
June 4th, 2007 at 12:30 pm
Glad I could help. If you have any other problems you can use my contact for to let me know, I would be happy to try and help out more if I can.
June 23rd, 2007 at 4:41 am
Good site - you’re a pretty good writer….. Very creative…