because we are on the internet.

Archives for Uncategorized category

 Foreach (array_expression as $value){

statement;

}

Foreach (array_expression as $key => $value){

statement;

}

for example

<?php

$arr = array(2,3,4,5) ;

foreach($arr as &$value){

$value = $value * 2;

}

//$arr now is array(4,6,8,10)

unset($value);//break the reference with the last element

//warning Reference of a $value and the last array element remain even after the foreach loop.It is recommended to destroy it by unset().

?>

<?php

$arr = array(”apply “,”orange”,”banana”);

reset($arr); //Set the internal pointer of an array to its first element

foreach($arr as $key => $value){

echo “Key:$key;Value:$value<br />\n”;

}

?>

get sign by birthday in php

Hello,I wrote some code for getting sign by birthday.

You need to create two file.

 One is the file with the the code below and name it as sign_form.php

<form action=”get_sign.php” value=”">

year:<input name=”year” valut=”" type=”text” /> <br />

month:<input name=”month” valut=”" type=”text” /> <br />

day:<input name=”day” valut=”" type=”text” /> <br />

submit:<input submit=”submit” valut=”submit” type=”submit” /> <br />

</form>

then have another file with the code as below and save it as get_sign.php

         if((date(m) > $_POST[’month’]) || (date(m) == $_POST[’month’] && $_POST[’day’] <= date(d))){
         $age = date(Y) - $_POST[’year’] + 1;
         }else{
         $age = date(Y) - $_POST[’year’];
         }
         if(($_POST[’month’] == 1 && $_POST[’day’] >= 21) OR ($_POST[’month’] == 2 && 19 >= $_POST[’day’])){
            $sign = “Aquarius”;
         } elseif(($_POST[’month’] == 2 && 20 <= $_POST[’day’]) OR ($_POST[’month’] == 3 && $_POST[’day’] <= 20)){
            $sign = “Pisces”;
         } elseif(($_POST[’month’] == 3 && 21 <= $_POST[’day’]) OR ($_POST[’month’] == 4 && $_POST[’day’] <= 20)){
            $sign = “Aries”;
         } elseif(($_POST[’month’] == 4 && 21 <= $_POST[’day’]) OR ($_POST[’month’] == 5 && $_POST[’day’] <= 20)){
            $sign = “Taurus”;
         } elseif(($_POST[’month’] == 5 && 21 <= $_POST[’day’]) OR ($_POST[’month’] == 6 && $_POST[’day’] <= 21)){
            $sign = “Gemini”;
         } elseif(($_POST[’month’] == 6 && 22 <= $_POST[’day’]) OR ($_POST[’month’] == 7 && $_POST[’day’] <= 22)){
            $sign = “Cancer”;
         } elseif(($_POST[’month’] == 7 && 23 <= $_POST[’day’]) OR ($_POST[’month’] == 8 && $_POST[’day’] <= 22)){
            $sign = “Leo”;
         } elseif(($_POST[’month’] == 8 && 23 <= $_POST[’day’]) OR ($_POST[’month’] == 9 && $_POST[’day’] <= 22)){
            $sign = “Virgo”;
         } elseif(($_POST[’month’] == 9 && 23 <= $_POST[’day’]) OR ($_POST[’month’] == 10 && $_POST[’day’] <= 23)){
            $sign = “Libra”;
         } elseif(($_POST[’month’] == 10 && 24 <= $_POST[’day’]) OR ($_POST[’month’] == 11 && $_POST[’day’] <= 22)){
            $sign = “Scorpio”;
         } elseif(($_POST[’month’] == 11 && 23 <= $_POST[’day’]) OR ($_POST[’month’] == 12 && $_POST[’day’] <= 21)){
            $sign = “Sagittarius”;
         } elseif(($_POST[’month’] == 12 && 22 <= $_POST[’day’]) OR ($_POST[’month’] == 1 && $_POST[’day’] <= 20)){
            $sign = “Capricorn”;
         }
         echo $sign;

 Then we just visit the sign_form.php and input the birthday and click submit,we will get the sign according the birthday.

 

About Author

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum at arcu. Integer et risus. Morbi id tellus. Integer felis. Mauris malesuada, turpis vitae facilisis euismod, dui arcu adipiscing sem, eu vulputate leo ante in lacus. Sed porta accumsan lectus. Aenean ac sem. In consequat tempus velit. Phasellus leo enim, adipiscing a, egestas nec, pretium ut, pede. Mauris sollicitudin diam et mauris. Sed quis enim vel augue egestas lobortis. Etiam tempus ipsum vel neque.