3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_position($string) { $vowels = array("a,e,i,o,u"); $first_letter = strtolower(substr($string,0,1)); echo $first_letter."<br>"; print_r($vowels); $new_string = ""; if( in_array($vowels,$first_letter) ) { $new_string = "an <strong>".ucfirst($string)."</strong>"; } else { $new_string = "a <strong>".ucfirst($string)."</strong>"; } return $new_string; } $output1 = get_position("Advertising"); $output2 = get_position("Marketing"); echo $output1."<br>"; echo $output2."<br>";
Output for git.master, git.master_jit, rfc.property-hooks
a<br>Array ( [0] => a,e,i,o,u ) Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /in/RkKTh:9 Stack trace: #0 /in/RkKTh(9): in_array(Array, 'a') #1 /in/RkKTh(17): get_position('Advertising') #2 {main} thrown in /in/RkKTh on line 9
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:
37.03 ms | 401 KiB | 8 Q