Reputation: 404
I have a json string sent from html...
[{"user_id":"test_123"},{"id":"wallName","value":"","type":"text"},{"id":"wallLength","value":"","type":"text"}]
I want to retrieve the "user_id":"test_123"
and then from that create a folder named test_123, maybe even a matching file named test_123. I'm thinking I need to convert the json file to an array, get the user_id
value and convert that back to a string? Does that make sense or am I over complicating this? I'm new to php so that might very well be the case.
Here's my php code...
<?php
$json=$_POST[json];
$decodedText=html_entity_decode($json);
$myArray = json_decode($json, true);
if (json_decode($json) != null){
$file=fopen('user_data.json','w+');
fwrite($file, $json);
fclose($file);
}else{
echo "empty";
}
?>
When I try to access $myArray
it doesn't work.
Upvotes: 2
Views: 104