92.5k views
3 votes
8. Write a PHP script which displays all the numbers between 200 and 250 that are divisible by 4.

9. Write a PHP script to get the shortest/longest string length from an array.

10. Write a PHP script to generate unique random numbers within a range.

11. Write a PHP script to get the largest key in an array.

12. Write a PHP function to generate a random password (contains uppercase, lowercase, numeric and other) using the shuffle() function.

13. Write a PHP script to sort an array in reverse order (highest to lowest).

14. Write a PHP script to trim all the elements in an array using the array_walk function.

15. Write a PHP script to lower-case and upper-case, all elements in an array.

16. Write a PHP function to check whether all array values are strings or not.

User Uri Shtand
by
7.9k points

1 Answer

2 votes

Final answer:

The student is looking to accomplish different tasks in PHP such as displaying numbers divisible by 4, finding string lengths, generating random numbers, and various array manipulations. Each task can be completed with a simple PHP script using loops and built-in PHP functions.

Step-by-step explanation:

Displaying all numbers between 200 and 250 that are divisible by 4 can be accomplished with a simple PHP script that iterates through the given range using a for-loop, checking divisibility, and then printing the number if the condition is met.

To determine the shortest and longest string lengths in an array, iterate over the array while keeping track of the lengths, and then update the minimum and maximum values accordingly.

$maxLength) {
$maxLength = $length;
}
}
echo "Shortest string length: " . $minLength . "\\";
echo "Longest string length: " . $maxLength . "\\";
?>

Similarly, generating unique random numbers, sorting an array in reverse order, trimming elements, changing case, and checking for string values can be achieved with appropriate PHP functions tailored for each specific requirement.

User Johntron
by
8.7k points