PHP - 用逗号将文本转换为数组变量,然后在IF语句中生成

Guys i have maybe a very simple question but i don't know how to make it.

How can i transform a following text into an array of variables.

$NotParsedString = "123456,654987,789456,321465";

foreach($results['data'] as $item){

    $PostID = $item['id'];
    if($PostID != $AnyIDfromNotParsedString){
        echo 'Show this thing';
    }
}

Simply i want to remove all the commas from $NotParsedString and make them as alone IDs which i can compare to $PostID and if $PostID is not same as any of theese IDs to echo 'Show this thing';

I hope you get the whole idea of what i am trying to do.

I want something like if $PostID is not equal to 123456 or if $PostID is not equal to 654987 and so on for the ones left till the end.

Can you help me out guys?

Thanks in advance!

Just use in_array() combined with explode() like this:

if(!in_array($PostID, explode(",", $NotParsedString))){

Just use the explode() function.

$NotParsedString = "123456,654987,789456,321465";
$ids = explode(',', $NotParsedString);

$ids will be as following.

Array
(
    [0] => 123456
    [1] => 654987
    [2] => 789456
    [3] => 321465
)