Friday, 18 December 2015

Make square pattern with star in PHP

<?php

for($i=1;$i<=5;$i++){
    for($j=1;$j<=5;$j++){
        if(($i==1 || $i==5) || ($j==1 || $j==5)){
            echo "*";
        }
        else{
           
            echo "&nbsp;&nbsp";
        }
    }
    echo "<br/>";
}


?>

Friday, 11 December 2015

Merge arrays without array_merge function using PHP.

<?php

$a = array(2,3,4,5);
$b = array(6,7,8,9);

$count = count($a);
for($i = 0; $i<count($b); $i++)
{
    $a[$count] = $b[$i];
    $count++;
}

print_r($a);

?>