3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function convertParametersForGetRequest( $lead ) { $parameters = ""; foreach( $lead as $key => $value ) { $parameters .= empty( $parameters ) ? "{$key}={$value}" : "&{$key}={$value}"; } return $parameters; } $a = [ 'gateway_id' => '1', 'email' => '2', 'firstName' => '3', 'lastName' => '4', 'genter' => '5', 'city' => '6', 'postalCode' => '7', ]; echo convertParametersForGetRequest($a);
based on LNpit
Output for 5.4.0 - 7.1.0
gateway_id=1&email=2&firstName=3&lastName=4&genter=5&city=6&postalCode=7
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/7JJER on line 15
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/7JJER on line 15
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/7JJER on line 15
Process exited with code 255.