Home » Php » Getting warning : implode(): after receiving a var value

Getting warning : implode(): after receiving a var value

Posted by: admin October 21, 2018 Leave a comment

Questions:

I am having the following errors:

Warning : array_map(): Argument #2 should be an array in…

Warning : implode(): Invalid arguments passed in wp-includes/class-wp-query.php on line 1918

On my php I am receiving a var from another page and I do:

$myId = $_POST['varPostId'];
$parts = explode(',', $myId);

And then I need to read that value

query_posts(array(
    'post__in' => $myId
));

But I get the above errors.

if I do:

    'post__in' => $parts
));

I get a blank page.

I tried using implode

$myId = $_POST['varPostId'];
$parts = implode(',', $myId);

And getting the value directly in the query

query_posts(array(
    'post__in' => $_POST['varPostId']
));

$_POST['varPostId'] is a single value like 405

Answers: