php - Warning: array_merge(): Argument #1 is not an array, when processing two $_POST
840
I'm receiving the following error Warning: array_merge(): Argument #1 is not an array when processing$_POST['cpl']
, although$_POST['add']
works fine
if (is_array($_POST['add'])) {
foreach ($_POST['add'] as $key => $value) $_POST['add'][$key] = mysql_real_escape_string($value);
$en = array_merge($en, $_POST['add']);
}
if (is_array($_POST['cpl'])) {
foreach ($_POST['cpl'] as $key => $value) $_POST['cpl'][$key] = mysql_real_escape_string($value);
$cp = '';
$cp = array_merge($cp, $_POST['cpl']);
}
Answer
Solution:
That's because
$cp
is a string (you explicitly defined it that way).should be:
Answer
Solution:
You have these lines:
It's self-explanatory:
$cp
is a string first, the error is simply about this fact. Initialize it witharray()
instead.