Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $contents = '{
- "intents": [{
- "name": "HelloIntent",
- "samples": ["Ciao", "Salve"],
- "responses": ["Ciao", "Buongiorno"]
- },
- {
- "name": "GoodbyeIntent",
- "samples": ["Addio", "Arrivederci"],
- "responses": ["Grazie per averci contattato!","Buona giornata !"]
- }
- ],
- "defaults":["Non ho capito", "Scusa, non ho capito"]
- }';
- $contentsDecoded = json_decode($contents, true);
- $value1 = "Stattbuon";
- $value2 = "Puratte";
- foreach($contentsDecoded['intents'] as $key => $intenti){
- if($intenti['name'] == "GoodbyeIntent"){
- array_push($contentsDecoded['intents'][$key]['samples'], $value1);
- array_push($contentsDecoded['intents'][$key]['responses'], $value1);
- }
- }
- $json = json_encode($contentsDecoded);
- print_r($json);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement