I have a doubt pass a code in php from a remote server to a local one to work in intranet. I am using WampServer 3.1.0 64bits and the code that used to work perfectly for me is now failing me. what I do is traverse a string and separate the letters of the number but I generate an error in all the lines where $ string appears [$ i] which for me does not make sense since it is already assumed to start the vector when passing the string in this case A1 so it would generate 2 memory fields $ string [0]="A" and $ string [1]="1" or at least that worked on the remote server. I do not know why it does not work now, what am I doing wrong?
Notice: Uninitialized string offset
$ CodGrupo is a parameter that leads by example A1
$Grupo='';
$Conteo='';
$cadena='';
$Retorna="";
$CodInventario="";
$CargarCodInventario=false;
$longitud =0;
$cadena=$CodGrupo;
$longitud = strlen($CodGrupo);
$longitud = strlen($CodGrupo);
for ($i=0; $i<=$longitud ;$i++){
if(is_numeric($cadena[$i])) {
//es numero
if($CargarCodInventario==true){
$CodInventario=$CodInventario.$cadena[$i];
}else{
$Conteo=$Conteo.$cadena[$i];
}
}else{
//no es numerico
//busca el guion
if($cadena[$i]=="-"){
$CargarCodInventario=true;
}else{
$Grupo=$Grupo.$cadena[$i];
}
}
}//fin for