Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function two($a, $t) {
- $b = $a;
- foreach($a as $k => $v) {
- unset($b[$k]);
- foreach($b as $bk => $bv) {
- if($v + $bv == $t) {
- return [$k, $bk];
- }
- }
- }
- return [];
- }
- print_r(two([1, -4, 6, 9, 4, 3, 8], 5));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment