在PHP我有一個這樣的數組:如何從數組中找到「http」字符串?
array
0 => string 'open' (length=4)
1 => string 'http://www.google.com' (length=21)
2 => string 'blank' (length=5)
,但它也可能是這樣的:
array
0 => string 'blank' (length=5)
1 => string 'open' (length=4)
2 => string 'http://www.google.com' (length=21)
現在很容易找到「空白」與in_array("blank", $array)
,但我怎麼可以看到,如果一個字符串以「http」開頭?
我試着
array_search('http', $array); // not working
array_search('http://www.google.com', $array); // is working
現在一切後`HTTP?可能會有所不同(如何寫不同,varie?可能不同,就是我的意思!)
現在我需要一個正則表達式嗎?或者我該如何檢查http
是否存在於數組字符串中?
感謝建議
也許這http://stackoverflow.com/questions/2354024/is-it-possible-to-use -regex-to-search-inside-an-array-using-php –
帶有strpos的foreach循環怎麼樣? –
那你[去](https://eval.in/96086),'preg_grep()'來救援! – HamZa