-
-
Save kemalkanok/27062bd683e48a84ef37 to your computer and use it in GitHub Desktop.
function hierarch in system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function test($a = "test") | |
{ | |
echo $a; | |
} | |
function search($word,$key) | |
{ | |
for($i=0;$i<strlen($word);$i++) | |
{ | |
if($word[$i] == $key) | |
{ | |
echo $i; | |
break; | |
} | |
} | |
} | |
/** | |
* @param $word bütün kelime | |
* @param $key aradığım harf | |
*/ | |
/*function searchMulti($word,$key) | |
{ | |
$results = []; | |
for($i=0;$i<strlen($word);$i++) | |
{ | |
if($word[$i] == $key) | |
{ | |
$results[] = $i; | |
} | |
} | |
print_r($results); | |
echo count($results); | |
}*/ | |
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