Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WP Plugin – Array Re: WP Plugin – Array

#78968
willB
Member

If you use explode():


$string = "1,324,34";
$posts_for_plugin = explode(',', $string);

You can pretty much leave your code that is getting the string from the dashboard the same.
So I guess in full if would be something like:


$post_id = 1;
$string = "1,324,34";
$posts_for_plugin = explode(',', $string);

if ( in_array($post_id, $posts_for_plugin) )
{
echo "Yep, it's in the array";
}
else
{
echo "Sorry, not in array";
}