Message: Undefined offset: 2

0

Hi, I'm trying to convert each one, separately, from the positions of an array to an integer I control it with a for, I look for information but I could not find how to pass each one, it just went through the entire array as a single variable and it's not what I need.

code:

    for ($i=0; $i < $sizeArrAdv ; $i++) {


    $Yhire_date = $this->ol_model->getyearHire($arrayAdvocates[$i]["roster_salesforcename"]);
    $Mhire_date = $this->ol_model->getmonthHire($arrayAdvocates[$i]["roster_salesforcename"]);

        $Mhire_daten[$i] = (int)$Mhire_date[$i]["month"];
        $Yhire_daten[$i] = (int)$Yhire_date[$i]["year"];

            echo "".$yearCn;
            echo ",".$monthCn;
            print_r(",".$Yhire_daten[$i]);




            //print_r($arrayAdvocates[$i]);


            $u=($yearCn-$Yhire_daten[$i]["amo"])*12;
            $d=$u+($monthCn-1);
            $t=$d-$Mhire_daten[$i]["mes"];
            $monthworked [$i]=$t;

    if ($monthworked[$i] > 11){

    $mworked = array('advocate' => $arrayAdvocates[$i]["roster_salesforcename"], 'Hire_Date' => $arrayhire_date[$i]["roster_hire_date"], 'Tenure' => $monthworked[$i], 'Type' => "T2", 'Bono' => "150.000");

     }

      array_push($arrayMtd, $mworked);
   }

I get this error right in these two lines which is where I try to make the conversion

    $Yhire_daten [$i]= (int)$Yhire_date[$i];
    $Mhire_daten[$i] = (int)$Mhire_date[$i];

error code:

Severity: Notice

Message: Undefined offset: 2

Filename: controllers/Admin.php

Line Number: 716

Backtrace:

File: C:\xampp\htdocs\olPrueba2\application\controllers\Admin.php
Line: 716
Function: _error_handler

File: C:\xampp\htdocs\olPrueba2\index.php
Line: 315
Function: require_once

but when I print the variable if it prints the number correctly but only the first time it enters the for then it prints them at 0 because that error comes out and as I correct it,

this is what the messages print the first time in the for how you see if you print the data correctly:

this is what prints the following cases:

    
asked by user80520 09.04.2018 в 19:04
source

0 answers