Skip to content

Instantly share code, notes, and snippets.

@kemalkanok
Created October 13, 2015 18:17
Show Gist options
  • Save kemalkanok/a0487c0873ecaa9c3e92 to your computer and use it in GitHub Desktop.
Save kemalkanok/a0487c0873ecaa9c3e92 to your computer and use it in GitHub Desktop.
function
function searchOne($word,$key,$start = 0)
{
for($i=$start;$i<strlen($word);$i++)
{
if($word[$i] == $key)
{
return $i;
}
}
return -1;
}
function searchMulti($word,$key)
{
$data = [];
$start = 0;
while(searchOne($word,$key,$start) > -1)
{
$start = searchOne($word,$key,$start);
$data[] = $start;
$start = $start +1;
}
var_dump($data);
}
searchMulti('muhammet','m');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment