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 –