Write a PHP program to create a new array using the first n strings from a given array of strings. (n>=1 and <=length of the array).
<?php function test($arr_str, $n) { $new_array = [sizeof($arr_str)]; for ($i = 0; $i < $n; $i++) { $new_array[$i] = $arr_str[$i]; } return $new_array; } $result = test(["a", "b", "bb", "c", "ccc"], 3); echo implode(" ",$result);
Sample Output:
a b bb
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