Vous êtes sur la page 1sur 4

// source code to PHP 2D-ARRAY

<html>

<body>

<?php

$favourate_games=array("indoor"=>array("carroms","chess","cards"),"outdoor"=>array("cricket","volly
ball","hockey"));

foreach($favourate_games as $category=>$games)

echo "<h3>my favourate" .$category. "games are:</h3>";

foreach($games as $game)

{ echo "<br>";

echo $game;

echo "<br>";

?>

</body>

</html>

// PROGRAM TO SORT ARRAY ELEMENTS

<?php

$games=array("Golf","cricket","Basket ball","volly ball","carraom","tennis");

print("<b> BEFORE SORTING</b>");

foreach($games as $game)

print "<BR>".$game;

sort($games);

print "<br><br>";
print("<b>AFTER SORTING</b>");

foreach($games as $game)

print "<BR>".$game;

?>

/*SORTING ASSOCIATIVE ARRAY U CAN CHECK ASORT,KSORT,RSORT,ARSORT,KRSORT WITH ALTERATION


OF SORT FUNCTION*/

<?php

$cse_books=array("java"=>800,"os"=>600,"php"=>650,"CN"=>400);

echo "<h3>BEFORE SORTING</h3>";

foreach($cse_books as $book_name=>$price)

echo "<br>".$book_name." ".$price;

arsort($cse_books);

echo "<h3>AFTER SORTING</h3>";

foreach($cse_books as $book_name=>$price)

print "<BR>".$book_name." ".$price;

?>

// REGULAR EXPRESSION PROGRAM IN PHP

<?php

if (preg_match("/ell/", "Hello World!", $matches)) {

echo "Match was found <br />";

echo $matches[0];

}
?>

// REGULAR EXPRESSION

<?php

if (preg_match("/ll.*/", "The History of Halloween", $matches)) {

echo "Match was found <br />";

echo $matches[0];

?>

// VALIDATION OF YOUR PASSWORD

<?php

$password = "Fyfjk34sdfjfsjq7";

if (preg_match("/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $password)) {

echo "Your passwords is strong.";

} else {

echo "Your password is weak.";

?>

//VALIDATION OF YOUR EMAIL IN PHP

<?php

$email = firstname.lastname@aaa.bbb.com;

$regexp = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";

if (preg_match($regexp, $email)) {

echo "Email address is valid.";


} else {

echo "Email address is <u>not</u> valid.";

?>

//