PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php //Given this: $foo = array(1, 3, 7); //write a function (on this whiteboard) to sum the values of the array. $sum = 0; foreach($foo as $f){ $sum += $f; } print($sum); //Given this: $text = 'Pick first and two last chars'; //write a function (on this whiteboard) to get first and last two chars. $len = strlen($text); $res = substr($text, 0, 2); $res = substr($text, 0, -2); print($res); ?>
Show:  
Copy Clear