Home>
I have JavaScript code that passes decoded JSON to another function.
I want to reproduce this in PHP.
I tried to find it, but I didn't understand it.
Thanks for your guidance and encouragement.
for (var i in json) {
message = message + json [i] .account.name + "\ n```" + json [i] .body + "` `` \ n ";
postMessage (message);
}
// Source: https://www.cg-method.com/entry/2017/03/06/080000/
-
Answer # 1
Related articles
- javascript php array
- [javascript] [php? ] i want to add a disabled attribute to the input tag created by php after clicking
- php - about wordpress and javascript jquery
- php - when javascript is set for the button set between form tags in laravel6, it malfunctions
- php - about compiling javascript code in laravel development
- php - about javascript document
- php - cannot load javascript on individual page of custom post
- i want to run javascript eventlistener on the html button element obtained from api (php)
Related questions
- javascript : Is it possible to specify multiple clsss of form->error?
- javascript : How to use JS frameworks with a regular php application?
- javascript : create a service for email verification [closed]
- javascript : How to connect a custom registration form to the database?
- javascript : Autocomplete input with selectable search?
- javascript : Refreshing the HTML page
- javascript : Replacing blocks at the touch of a button
- javascript : Best Platform for Site Performance (PageSpeed Insights)
- php : Ajax, Privat24-api: invalid signature error
- javascript : The modal window opens only for one record
You may want to imitate the for-in grammar as it is, but
Enter the town and follow the town,
I think it should be used if there is a more convenient grammar.
Assuming that a certain data structure is processed one by one from the beginning to the end,
Then it is the idea that foreach is good.
If you want to be aware of what number of data is being processed,
Assuming that the arguments are 0,1,2, and so on, using the count function is a hand.
When decoding a json string with the json_decode function,
You can choose between objects and arrays.
I thought that I should handle it in a foreach loop.
Sample json data was not shown, so prepare sample data without permission,
I wrote a sample code.
Example of decoding into an object:
Example of decoding into an array:
Example for for instead of foreach: