Matrix does not show negative numbers

0

I want to add the line and in the main line of the matrix put the negative number to zero the line, however when I put the value receiving * -1 the matrix only takes the - and not the number together, what I am doing wrong ?

class Matrizes {
  private $primeiro = true;

    public function matrizCTMC(){
        $f = file("matriz/matriz.txt");
        $max = count($f);
        $valor = 0;

       for ($x = 0; $x < $max; $x++) {
           for($y = 0; $y < 2*$max; $y++){

               $valor += $f[$x][$y];
               $y++;

           }

        $aux=$x;

        if($x==$aux){
            if($this->primeiro==true){
            $valor *=-1;
            $f[$x][$aux] = $valor;
            echo "valor= $valor<br>";
            $valor=0;
            $aux = 0;
            $this->primeiro=false;
            }else{

                $aux =$aux*2;
                $valor *=-1;
                $f[$x][$aux] = $valor;
                echo "valor= $valor<br>";
                $valor=0;

            }
        }   

       }

       foreach($f as $item){
        echo $item .'<br>';
        }

    }
}
    
asked by anonymous 01.04.2018 / 02:03

0 answers