3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function testFunction($var) { if ($var == 1) return "<div>Hello World from function1</div>"; if ($var == 7) return "<div>Hello World from function7</div>"; if ($var == 2) return "<div>Hello World from function2</div>"; if ($var == 3) return "<div>Hello World from function3</div>"; if ($var == 4) return "<div>Hello World from function4</div>"; if ($var == 5) return "<div>Hello World from function5</div>"; if ($var == 6) return "<div>Hello World from function6</div>"; } $functions1 = 7; //users can select this value and this can be something between 1-7 $functions2 = 5; //these values are positions to be precise $functions3 = 6; //no two variables can have same value as each position is unique $functions4 = 3; //we can also make $functions1-7 an array to avoid making 7 variables $functions5 = 4; $functions6 = 2; $functions7 = 1; $array = array($functions1, $functions2, $functions3, $functions4, $functions5, $functions6, $functions7); for ($i = 0; $i<count($array); $i++) echo testFunction($array[$i]);
based on GXmrO
Output for 4.3.0 - 7.1.0
<div>Hello World from function7</div><div>Hello World from function5</div><div>Hello World from function6</div><div>Hello World from function3</div><div>Hello World from function4</div><div>Hello World from function2</div><div>Hello World from function1</div>