Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Last active August 3, 2018 00:46
Show Gist options
  • Save hasinhayder/2b41357892f3cd23e5d319ebe1c07bc8 to your computer and use it in GitHub Desktop.
Save hasinhayder/2b41357892f3cd23e5d319ebe1c07bc8 to your computer and use it in GitHub Desktop.
create mxn matrix
<?php
$i1 = 2; //m
$i2 = 3; //n
//your requirement was that you will add 1 to the incoming data, here $i1 and $i2 - so added 1 with $i1 and $i2 in the loop below
$matrix = array();
for($j=1;$j<=($i1+1);$j++){
$_row = array_fill(0, ($i2+1), 0);
array_push($matrix,$_row);
}
print_r($matrix);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment