Write a PHP program to create a new string of length 2 starting at the given index of a given string.
<?php function test($s1, $index) { return $index + 2 <= strlen($s1) ? substr($s1, $index, 2) : substr($s1, 0, 2); } echo test("Hello", 1)."\n"; echo test("Python", 2)."\n"; echo test("on", 1)."\n";
Sample Output:
el th on
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output: