html5andphp: November 2014

Saturday, 22 November 2014

Special loop keyword



How to use special loop keyword :- continue and break



There are two special keyword available for looping

1. Continue 

2. Break


Continue :- Continue keyword is used to continue the block of code while condition is false following example explain the concept of continue and break keyword.




<?php
for ($i = 1; $i < 10; $i++)
{
if ($i == 5)
{
echo("Loop continued at $i<BR>");
continue;
}
if ($i == 8)
{
echo("Loop terminated at $i<BR>");
break;
}
echo("Number $i<BR>");
}
?>



Break:- Break keyword is used for unconditional jump, above example explain the concept of break keyword.



If you want to learn more about php visit php tutorial and download php basic tutorial 

Thursday, 13 November 2014

how to embed php into html




How to embed PHP into html

<html>
<head>
<title>html embeded code</title>
</head>
<?php
echo "welcome to the php";
echo "<br />";
echo "Html and php script embed<hr>";
echo "<b>"."hello friends"."<b>";
?>
<body>
</body>
</html>

Explanation

You can put your PHP script anywhere in our html code. Above example explain the following concept.

Another example of php into the html

<html>

<head>

<title>


<?php

echo "Title of your page";

 ?>

</title>

</head>

<body>

<?php

echo "welcome to the php";

echo "<br />";

echo "Html and php script embed<hr>";

echo "<b>"."hello friends"."<b>";

?>



</body>

<?php

echo "web come to php" ?>
</html>

explaination

Note :You can put php script any number of times in your html page like that.

If you want to learn more about visit

php tutorial

Download PHP PDF php basic tutorial

Wednesday, 12 November 2014

Array sorting in array


Sorting in array


<?php
$uk=array(6,5,8,99,55,66,22,11,45,68,95,100,1,50,32,64,51,95,22,77,32,66,33);
rsort($uk);
echo" sorting using rsort() function<br> ";
foreach( $uk as $value )
{
echo "Value is $value <br />";
}
echo"<br><br><br>";

$uk1=array(6,5,8,99,55,66,22,11,45,68,95,100,1,50,32,64,51,95,22,77,32,66,33);
echo" sorting using sort() function";
sort($uk1);

foreach( $uk1 as $value )
{
echo "Value is $value <br />";
}
echo"associative array sorting<br>";
$uk2=array("a"=>100,"d"=>1,"h"=>15,"b"=>50);
asort($uk2);
echo "value of uk in index a: $uk2[a] <br>";
$abc= key($uk2);
$bc= current($uk2);
echo " index=$abc<br>";
echo "value=$bc <br>";

echo"associative array arsorting<br>";
$uk4=array("a"=>5,"d"=>1,"h"=>15,"b"=>50);
arsort($uk4);
echo "value of uk in index a: $uk4[a] <br>";
$abc1= key($uk4);
$bc1= current($uk4);
echo " index=$abc1<br>";
echo "value=$bc1 <br>";

echo"<br><br><br><br>using prev and next<br>";
$sk=array(6,5,8,99,55,66,22,11,45,68,95,100,1,50,32,64,51,95,22,77,32,66,33);
echo "current value="."".current($sk)."<br>";
echo "next value= "."".next($sk)."<br>";
echo "previos value= "."".prev($sk)."<br>";

echo"<br><br><br><br>using list and each<br>";
$sk=array("a"=>5,"d"=>1,"h"=>15,"b"=>50);
while( list($a,$b)=each($sk))
{
 echo"index=$a-value=$b<br>";
}

echo"<br><br><br><br>using ksort<br>";
$sk2=array("z"=>5,"d"=>1,"h"=>15,"a"=>50);
ksort($sk2);
while( list($a1,$b1)=each($sk2))
{
 echo"index=$a1-value=$b1<br>";
}

?>

for more detail on php visit php-tutorial

Download php tutorial pdf php basic tutorial pdf