夥計們,我可能有一個非常簡單的問題,但我不知道如何製作它。PHP - 使用逗號將變量文本轉換爲數組變量並在IF語句中生成後
如何將下列文本轉換爲變量數組。
$NotParsedString = "123456,654987,789456,321465";
foreach($results['data'] as $item){
$PostID = $item['id'];
if($PostID != $AnyIDfromNotParsedString){
echo 'Show this thing';
}
}
只要我想從$NotParsedString
刪除所有的逗號,讓他們作爲單獨的ID,我可以比較$PostID
如果$PostID
不與任何theese ID到echo 'Show this thing';
我希望你能我想要做什麼的整個想法。
我想要一些像if $PostID is not equal to 123456
或if $PostID is not equal to 654987
等到剩下的結束。
你能幫我出去嗎?
在此先感謝!
1. http://php.net/manual/en/function.explode.php 2. http://php.net /manual/en/function.in-array.php – Sammitch 2015-04-01 22:40:21
你的預期輸出是什麼? – Rizier123 2015-04-01 22:50:58
我已更新我的問題 – 2015-04-01 22:54:01