5 * 5 matrix with column multiplied by row in php


OutPut:

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

Code:
<?php
// Your code here!
for($i=1;$i<=5;$i++){
    echo $i;// $i as row 
   for($j=1;$j<5;$j++){ // $j as column
        echo  " ";
        echo ($j+1)*$i;    
     }
    echo "\n";
}
?>
Tagged with: , ,
Posted in matrix php, php, php interview question

add and call anonymous function in class php


Adding anonymous function and call the public variable in an anonymous function by using magic function called __invoke();

 

<?php
// Your code here!
class model
{
public $greet;
public $a =”hello”;
function __construct()
{
$this->greet = function(){
echo $this->a;
};
}
}
$model = new model();
$model->greet->__invoke();
?>

Tagged with: , , , ,
Posted in php

finding pair of n numbers using php


I found this post use-full as it groups the n number .

Find pair of n numbers in php

Posted in php

How to repair a zip file in mac


Hello Friends

Recently i was working in project ,where i got code in zip file and was unable to unzip as it failed with error 2 ,so i got solution from google search i tried several method in which below command in terminal helped.

zip -FF knights.zip —out ~Downloads/New_knights.zip
Tagged with: , , , , , , ,
Posted in mac

Reset or delete the local changes and pull latest git


This command reset local changes and remove the files in local changes and pulls the latest code from git.Please add branch name in pull command.

Command:

git reset –hard

git clean -fxd

git pull origin /* your Branch */

Tagged with: , , , ,
Posted in Practice Makes a beginner to become php programmer expert(practical task to become php programmer)
Follow Tutorial on WordPress.com
categories
Calendar
May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
Follow me on Twitter
Blog Stats
  • 88,191 hits