3

@3373_vaishnavi

String fun (1)strlen()

PHP
1 year ago
<?php $string="Hello India"; $length=strlen($string); echo $length; ?>

Foreach loop in PHP ex.2M

PHP
1 year ago
<?php $fruits=array("Apple","Banana","Cherry"); foreach($fruits as $fruit){ echo "$fruit\n"; } ?>

Array flip function ex.in 2m

PHP
1 year ago
<?php $fruits=array( "a"=>"apple", "b"=>"banana", "c"=>"cherry ", ); $flipped=array_flip($fruits); print_r($flipped); ?>

Compact function in ex.php 4 m

PHP
1 year ago
<?php $name= "Raj"; $age = "20"; $city= "Pune"; $person= compact ("name","age","city"); print_r($person); ?>

Function in php ex.

PHP
1 year ago
<?php function add($a,$b){ return $a+$b; } $result=add(5,10); echo$result; ?>

Explode function in PHP ex.

PHP
1 year ago
<?php $string= "apple,banana,cheery"; $fruitsArray=explode (".",$string); print_r($fruitsArray); ?>

Implode function ex.

PHP
1 year ago
<?php $fruits=array ("apple","banana","cheery"); $fruitsstring=implode(".",$fruits); echo$fruitsstring; ?>

Extract data ex.in associative array

PHP
1 year ago
<?php $person=array ("name"=>"Rakhi","Age"=>20,"Roll no"=>104); echo $person["name"]."\n"; echo $person["Age"],"\n"; echo $person["Roll no"]; ?>

multidimensional array in Ex.php

PHP
1 year ago
<?php // Define a multidimensional array $students = array( array( "name" => "Tara", "scores" => array( "Math" => 80, "Science" => 92, "English" => 78 )

Array an 8 elements

PHP
1 year ago
<?php $numbers=array("1","2","3","4","5","6","7","8","9"); echo "$numbers[8]";

Ex.array

PHP
1 year ago
<?php $colours=array("Red","yellow ","Green"); echo$colours[0]; ?>

Ex.2.for each loop

PHP
1 year ago
<?php $students=array("Alice"=>85,"Bob"=>78,"Charlie"=>92); foreach($students as $name=>$score){ echo"$name scored $score\n"; }

Ex.2.for each loop

PHP
1 year ago
<?php $students=array("Alice"=>85,"Bob"=>78,"Charlie"=>92); for each($students as $name=>$score){ echo"$name scored $score\n"; }

Ex.for each loop

PHP
1 year ago
<?php $fruits=array("Apple","Banana","Cherry"); for each($fruits as $fruit) { echo"Fruit:$fruit\n"; }

Ex..for loop

PHP
1 year ago
<?php for($i=0;$i<3;$i++){ echo"value of i is:$i \n"; } ?>

Ex..do. while loop

PHP
1 year ago
<?php $count=0; do{ echo "count is:$ count\n"; $count++; } while ($count<3);

Ex..While loop

PHP
1 year ago
<?php $count=0; while ($count<3){ echo"count is:$count \n"; $count++; }

If..elseif..else statement with ex.

PHP
1 year ago
<?php $score = 85; if ($score >= 90) { echo "Grade: A"; } elseif ($score >= 80) { echo "Grade: B"; } elseif ($score >= 70) { echo "Grade: C"; } elseif ($score >= 60) {

Switch break statement ex.php

PHP
1 year ago
<?php $country=25; switch ($country){ case 25: echo"india"; break; case 21: echo"Nepal"; break; case 23:

Switch break statement php

PHP
1 year ago
<?php $day = 3; switch ($day) { case 1: echo "Monday"; break; case 2: echo "Tuesday"; break;