{"id":532,"date":"2023-01-30T19:21:05","date_gmt":"2023-01-30T19:21:05","guid":{"rendered":"https:\/\/mouryasolutions.in\/blog\/?p=532"},"modified":"2023-01-30T19:40:52","modified_gmt":"2023-01-30T19:40:52","slug":"matrix-program-in-php-2","status":"publish","type":"post","link":"https:\/\/mouryasolutions.in\/blog\/matrix-program-in-php-2\/","title":{"rendered":"Matrix program in php"},"content":{"rendered":"<div class=\"post-content\">\r\n<blockquote class=\"wp-block-quote\">\r\n<p>Here&#8217;s an example of how you can create a matrix program in PHP:<\/p>\r\n<\/blockquote>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>&lt;?php\r\n\r\n\/\/ Define the matrix size\r\n$rows = 3;\r\n$cols = 3;\r\n\r\n\/\/ Initialize the matrix\r\n$matrix = array();\r\nfor ($i = 0; $i &lt; $rows; $i++) {\r\n  for ($j = 0; $j &lt; $cols; $j++) {\r\n    $matrix[$i][$j] = 0;\r\n  }\r\n}\r\n\r\n\/\/ Fill the matrix with values\r\nfor ($i = 0; $i &lt; $rows; $i++) {\r\n  for ($j = 0; $j &lt; $cols; $j++) {\r\n    $matrix[$i][$j] = $i * $cols + $j + 1;\r\n  }\r\n}\r\n\r\n\/\/ Print the matrix\r\nfor ($i = 0; $i &lt; $rows; $i++) {\r\n  for ($j = 0; $j &lt; $cols; $j++) {\r\n    echo $matrix[$i][$j] . \" \";\r\n  }\r\n  echo PHP_EOL;\r\n}\r\n\r\n?&gt;\r\n<\/code><\/pre>\r\n\r\n\r\n\r\n<p>This will create a 3&#215;3 matrix with values from 1 to 9. You can change the <code>$rows<\/code> and <code>$cols<\/code> variables to define the size of the matrix, and modify the code in the <code>for<\/code> loops to fill the matrix with different values.<\/p>\r\n<\/div><!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s an example of how you can create a matrix<a href=\"https:\/\/mouryasolutions.in\/blog\/matrix-program-in-php-2\/\">Read More<i class=\"fa fa-long-arrow-right\" aria-hidden=\"true\"><\/i><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/532"}],"collection":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=532"}],"version-history":[{"count":3,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":540,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/posts\/532\/revisions\/540"}],"wp:attachment":[{"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mouryasolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}