From 8ab689705c3e1a128ed9b73bf625bd06e4a75ab3 Mon Sep 17 00:00:00 2001 From: animeshprasad15 <56110479+animeshprasad15@users.noreply.github.com> Date: Sun, 13 Oct 2019 23:24:58 +0530 Subject: [PATCH] updated learning_php --- part2.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/part2.php b/part2.php index 7a23255..ea498a1 100644 --- a/part2.php +++ b/part2.php @@ -34,16 +34,30 @@ they are very flexible just like python lists, and you can change each element, also, you can add elements just as simple as, $friend[4] = "something" <--- if the friend array initially contained 3 elements. + + and we can create a constant valued array of desired length using the following function: + array_fill((int: start index),(int: number of elements),(value to be put)); + + example: + + + the output of above code will be: + Array + ( + [5] => "bosecodes" + [6] => "bosecodes" + + ) */ $friends = array("Kevin", true, 43.43, "Oscar"); $friends[2] = "Dwayne"; $friends[4] = "Angela"; - echo $friends[2]; - echo "
"; - echo $friends[4]; - echo "
"; - echo count($friends); - echo "
"; + echo $friends[2]."
"; + echo $friends[4]."
"; + echo count($friends)."
"; echo "Roses are $color
"; echo "$plural are blue
";