PHP Exercises
1. Write a program to compare between things that are not integers. Suppose the strings are -
$str1 = "00004";
$str2 = "008";
$str3 = "00007-STR";
6. Write a program to convert the given string into an array. Suppose the string is -
$a = 'Burch Jr, Philip H., The American establishment, Research in political economy 6(1983), 83-156';
7. Write a php program to loop over the json data. Suppose, you have the following json data.
[
{
"name" : "John Garg",
"age" : "15",
"school" : "Ahlcon Public school"
},
{
"name" : "Smith Soy",
"age" : "16",
"school" : "St. Marie school"
},
{
"name" : "Charle Rena",
"age" : "16",
"school" : "St. Columba school"
}
]
9. Write a program to loop through an associative array using foreach. Suppose an associative array is -
$a = array('one' => 'I', 'two' => 'II', 'three' =>'III', 'four' => 'IV');
12. There are two deals of an item to buy. The quantities and prices of the item are given below. Write a program in PHP to find the best deal to purchase the item.
$quantity1 = 70;
$quantity2 = 100;
$price1 = 35;
$price2 = 30;