Use of json_decode to cast different data type - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Use of json_decode to cast different data type.php
- <?php
- $data = [ '{fdass]', '', 'hi2', 'Check slashes \fasdfa \n ok', 'ññññ', '3hello', '-4', '2', '-3.2', 'false', 'true', '[]' ];
- foreach($data as $i => $val){
- $decode = json_decode( $val );
- if( is_null($decode)){
- echo "\n$i-result: " . $val . "\t\ttype: " . gettype($val);
- } else {
- echo "\n$i-result: " . print_r($decode, true) . "\t\ttype: " . gettype($decode);
- }
- }
File Description
- Use of json_decode to cast different data type
- PHP Code
- 22 Jan-2021
- 411 Bytes
You can Share it:
Latest PHP Pastes