Following function implements a way to find all the indices of a given $needle in $haystack. There is at least one bug in the implementation. Find and fix the bug(s).
<?php
function findAllIndices($haystack, $needle) {
$indices = array();
while ($index = strpos($haystack, $needle)) $indices[] = $index;
return $indices;
}
Shikha_1
-4
Light Poster
Recommended Answers
Jump to PostI can see the errors, but this looks like it is for your homework.
Please be polite, and dont just paste the question.
All 3 Replies
Szabi Zsoldos
26
Learner and helper guy
sujeet.rnc
0
Newbie Poster
almostbob
866
Retired: passive income ROCKS
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.