Write a PHP program to create a string like "aababcabcd" from a given string "abcd"
<?php function test($s) { $result = ""; for ($i = 0; $i < strlen($s); $i++) { $result = $result.substr($s, 0, $i + 1); } return $result; } echo test("abcd")."\n"; echo test("abc")."\n"; echo test("a")."\n";
Sample Output:
aababcabcd aababc a
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:
need an explanation for this answer? contact us directly to get an explanation for this answer