Advertisement
AmourSpirit

PHP Loop nested Array - String Replace

Jul 20th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2. // http://phpfiddle.org/lite/code/rem2-icej
  3. $myarray = array(array("'CALL #__comm_repair_count_dates_by_id ('2015-07-01 00:00:00', '2015-07-31 23:59:59', 842, '5,1,3', @c);'",
  4.                        "'Call #__commissions_by_date_user_wo ('2015-07-01 00:00:00', '2015-07-31 23:59:59', %1,'5,1,3',1.3,842);'"),
  5.                  array("'CALL #__comm_repair_count_dates_by_id ('2015-08-01 00:00:00', '2015-08-31 23:59:59', 842, '5,1,3', @c);'",
  6.                        "'CAll #__commissions_by_date_user_wo ('2015-08-01 00:00:00', '2015-08-15 00:00:00', %1,'5,1,3',1.3,842);'"));
  7. echo '<pre>';
  8. var_dump($myarray);
  9. echo '</pre>';
  10.  for ($i = 0; $i < count($myarray); ++$i) {
  11.      for($j = 0;$j <count($myarray[$i]); ++$j) {
  12.          if($j == 1) {
  13.              print str_replace('%1',33.4,$myarray[$i][$j]) . '<br />';
  14.          } else {
  15.             print $myarray[$i][$j] . '<br />';
  16.          }
  17.          
  18.      }
  19.    }
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement