Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 26, 2018 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/e52397df52a07a5a40227c9904e75f98 to your computer and use it in GitHub Desktop.
Save parzibyte/e52397df52a07a5a40227c9904e75f98 to your computer and use it in GitHub Desktop.
<?php
# Esto puede venir de cualquier lugar, aquí lo ponemos en una variable directamente
$codificado = '{"idCuenta":"123ASD","cliente":"parzibyte","saldo":250,"movimientos":[{"tipo":"salida","monto":125,"fecha":"2018-12-25","involucrados":{"nombre":"Un nombre","idCuenta":"456465"}},{"tipo":"salida","monto":666.55,"fecha":"2018-12-26"}]}';
$comoObjeto = json_decode($codificado);
echo "El saldo es: " . $comoObjeto->saldo . "\n";
$comoArreglo = json_decode($codificado, true);
echo "El saldo es: " . $comoArreglo["saldo"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment