Write a PHP program to count the number of strings with given length in given array of strings
<?php function test($arr_str, $len) { $ctr = 0; for ( $i = 0; $i < sizeof($arr_str); $i++) { if (strlen($arr_str[$i]) == $len) $ctr++; } return $ctr; } echo test(["a", "b", "bb", "c", "ccc"], 1)."\n";
Sample Output:
3
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