Advertisement
upcesar

Ejemplo JSON / PHP

Feb 19th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. //Pruebas con enteros
  2.  
  3. $a_value = 1;
  4. $b_value = 0;
  5. $c_value = 1;
  6.  
  7. $int_feature = array("A" => $a_value,
  8.                      "B" => $b_value,
  9.                      "C" => $c_value,
  10.                      );
  11.  
  12. $featureJsonInt = json_encode($int_feature);
  13.  
  14. echo "Entero: " . $featureJsonInt." | ";
  15.  
  16. $resultado_int = json_decode($featureJsonInt);
  17.  
  18. var_dump($resultado_int);
  19.  
  20. //Pruebas con Strings
  21. $a_str_value = "1";
  22. $b_str_value = "0";
  23. $c_str_value = "1";
  24.  
  25. $str_feature = array("A" => $a_str_value,
  26.                      "B" => $b_str_value,
  27.                      "C" => $c_str_value,
  28.                      );
  29.  
  30. $featureJsonStr = json_encode($str_feature);
  31.  
  32. echo "String: ". $featureJsonStr." | ";
  33.  
  34. $resultado_str = json_decode($featureJsonStr);
  35.  
  36. var_dump($resultado_str);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement