1
我無法從PHP中的URL列表中獲取特定文本。 這裏是網址範例檢查字符串是否包含具有數字的特定字符PHP
$arrString = array(
"http://example.expl/text-t350/",
"http://example.expl/text-t500-another-text/"
"http://example.expl/text-t20/text-example/"
);
我只需要 'T' 字用TE號: T350 T500 T20
我試過如下:
foreach ($arrString as $key => $value) {
if (strpos($value, "t".filter_var($value, FILTER_SANITIZE_NUMBER_INT)) !== true) {
echo "Url with t price ".$value."<br>";
}
}
但沒有工作;(
希望你能幫助我...
謝謝inadvance!
您需要使用正則表達式。 –
你是什麼意思?你能告訴我一個例子嗎? – Emin
在PHP中使用正則表達式,你可以很容易地從URL分離tnum ...檢查這個鏈接,你會得到的資源... http://www.tutorialspoint.com/php/php_regular_expression.htm –