I'm sending an array from javascript to PHP file. When doing echo $newArray inside the .php file, it shows me the array correctly:
array(4) { ["titulo"]=> string(28) "Curso de canvas y Javascript ["cantidad"]=> string(1) "1" ["valorItem"]=> string(2) "10"["idProducto"]=> string(3) "403" }
array(4) { ["titulo"]=> string(15) "Curso de jQuery" ["cantidad"]=> string(1) "1" ["valorItem"]=> string(2) "10"["idProducto"]=> string(3) "402" }
How do I access some element of the array? I have tried with this:
$newArray = $_POST["array"];
$title = json_decode($newArray[0]["titulo"]);
echo $title;
But this appears:
Warning: Illegal string offset 'titulo' in C:\xampp\htdocs\frontend\controladores\carrito.controlador.php on line 78
I tried everything that says in other questions of this type in the stack, but it has not worked