I make a program to create an array with the range of my hero :
public function surface($fighterId,$porte_max,$porte_min){
$porte = $porte_max;
$longeur = 0;
$surface;
$i =0;
$coordonne_x=$this->findById($fighterId, array('field'=>'coordinate_x'));
$coordonne_y=$this->findById($fighterId, array('field'=>'coordinate_y'));
for( $for = ($coordonne_y['Fighter']['coordinate_y'] - $porte) ; ($coordonne_y['Fighter']['coordinate_y'] + $porte) ; $for++)
{
for( $for2 = ( $coordonne_x['Fighter']['coordinate_x'] - $longeur) ; ($coordonne_x['Fighter']['coordinate_x'] + $longeur) ; $for2++)
{
$surface[$i] = '[' . $for . '|' . $for2 . ']';
$i++;
}
if ($longeur < $porte)
{
$longeur++ ;
}
else $longeur-- ;
}
return $surface;
}
I don't understand the error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /var/www/html/WebArenaGroupSI4-02-AF/app/Model/Fighter.php on line 36
This is the issue with PHP memory has been exhausted. You can change your PHP
memory limit
in php.ini. Then restart your server.Also your code has an endless for, the correct syntax for a for statement is like the following
But in your condition, you did not put any conditions but instead did calculation in that.