Last active
October 12, 2023 04:12
-
-
Save 4RSIM3R/ad304eedeb496a436cb2b924555bc255 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// di berikan sebuah angka, cari posisi index angka tersebut dalam array | |
// input : arr = [1, 2, 3, 4, 5], i = 3 | |
// output : 2 | |
// input : arr = [1, 2, 3, 4, 5], i = 9 | |
// output : -1 | |
function findMe($arr, $i) | |
{ | |
return -1; | |
} | |
$arr = [1, 2, 3, 4, 5]; | |
$result = findMe($arr, 3); | |
echo json_encode($result); // 2 | |
echo "<br />"; | |
$arr = [1, 2, 3, 4, 5]; | |
$result = findMe($arr, 9); | |
echo json_encode($result); // -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment