In Perl, we could do like this:
foreach (....) {
..........
..........
..........
my @tmp = ($x1,$x2,$y1,$y2);
push(@target_array,\@tmp); # Don't know how to translate this line to PHP, failed after several try with array_push
}
How to translate this into PHP?
For add new array value you can use. i assume that you have length for loop.
$target_array = array();
for(....) {
..........
..........
..........
$tmp = array($x1,$x2,$y1,$y2);
$target_array[][] = $tmp;
}
or you can
for(....) {
..........
..........
..........
$tmp = array($x1,$x2,$y1,$y2);
array_push($target_array,$tmp);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.