【发布时间】:2014-03-19 01:40:12
【问题描述】:
是否有现成的函数来获取位置数组,某个子字符串从哪里开始?
例如,
$needle = "apple";
$haystack = "one apple two apples three apples";
$r = f($haystack , $needle);
// should give:
$r = array(4 , 13 , 24);
// i.e. the positions of "a" letters
我知道 substr_count 给出了子字符串的数量,但是我怎样才能得到起始位置呢?
感谢您的帮助!
【问题讨论】:
标签: php arrays substr substring