Home › Forums › Back End › WP Plugin – Array › Re: WP Plugin – Array
September 28, 2010 at 12:39 am
#78968
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";
}