3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = '1234567'; $array = ['1', '12', '123', '1234', '456', '56', '7', '3456', '234567']; function get_best_prefix($input, $array, $limit = -1, &$count){ $best = ''; $sizeBest = 0; foreach ($array as $data) { if (strpos($input, $data) === 0) { $current = strlen($data); if($sizeBest < $current){ $sizeBest = $current; $best = $data; } } } return $best; } echo get_best_prefix($input, $array);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Optional parameter $limit declared before required parameter $count is implicitly treated as a required parameter in /in/p5ai7 on line 7 Fatal error: Uncaught ArgumentCountError: Too few arguments to function get_best_prefix(), 2 passed in /in/p5ai7 on line 26 and exactly 4 expected in /in/p5ai7:7 Stack trace: #0 /in/p5ai7(26): get_best_prefix('1234567', Array) #1 {main} thrown in /in/p5ai7 on line 7
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.32 ms | 402 KiB | 8 Q