json_decode,试图访问数组元素

$objetos = json_decode($_POST['objetos']);

$query1 = "DELETE FROM `usuarioObjeto` WHERE idusuario=" . $id . "";
$result1 = mysqli_query($conn, $query1) or die('Consulta fallida: ' . mysqli_error());



$size = count($objetos); //this  works

//this do not insert into the BD

for ($k = 0; $k < $size; $k++) {
    $ido = intval($objetos[$k]['id']);
    $cantidad = intval($objetos[$k]['cantidad']);
    $query2 = "INSERT INTO `usuarioObjeto`( `idUsuario`, `idObjeto`, `cantidad`) VALUES (" . $id . "," . $ido . "," . $cantidad . ")";
    $result2 = mysqli_query($conn, $query2) or die('Consulta fallida: ' . mysqli_error());
}

thanks

and i have tried to access to one property like this but nothing

$ido = intval($objetos[0]['id']); 

json_decode($_POST['objetos']); replece to json_decode($_POST['objetos'],true);

By adding true as a second parameter, it will convert your json to array

More information: json_decode

Use this code :

$objetos = json_decode($_POST['objetos'],true);