11. Write a PHP script to create an associative array of three students with their grades and print one student's grade.

Required Input:

An associative array of students with their grades (e.g., ["John" => 85, "Alice" => 90, "Bob" => 78]).

Expected Output:

90

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

12. Create a PHP script that uses a while loop to print numbers 5 to 15.

Required Input:

No input required.

Expected Output:

5 6 7 8 9 10 11 12 13 14 15 

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

13. Write a PHP script to find the largest number among three variables $x = 10, $y = 20, $z = 5.

Required Input:

Three predefined variables: $x, $y, and $z.

Expected Output:

20

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

14. Write a PHP script to reverse a string $word = "Hello".

Required Input:

A predefined string $word.

Expected Output:

olleH

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

15. Create a PHP script to demonstrate the use of the strlen() function to find the length of a string.

Required Input:

A predefined string (e.g., "Learn PHP").

Expected Output:

9

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

16. Write a PHP script to check if a number $x is positive, negative, or zero.

Required Input:

A predefined variable $x (e.g., 0).

Expected Output:

Zero

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

17. Create a PHP script to use a foreach loop to iterate over an array of colors and print each color.

Required Input:

An array of colors (e.g., ["Red", "Green", "Blue"]).

Expected Output:

Red
Green
Blue

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

18. Write a PHP script to find the sum of all elements in an array [1, 2, 3, 4, 5].

Required Input:

An array of numbers.

Expected Output:

15

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

19. Create a PHP script to demonstrate the use of the explode() function to split a string into an array.

Required Input:

A string (e.g., "PHP,JavaScript,Python").

Expected Output:

["PHP","JavaScript","Python"]

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

20. Write a PHP script to use the date() function to display the current date in Y-m-d format.

Required Input:

No input required.

Expected Output:

The current date (e.g., 2024-11-12).

Code In Php

<?php // Write code to here ?>

Run Code?

Click Run Button to view compiled output

ad vertical

2 of 3