for example, how to judge whether the length of JSON reaches three. If only MCVersion,JavaVersion lacks Server, it indicates that JSON is incomplete. How to implement
{"MCVersion":"v1.10.0","JavaVersion":"v1.8","Server":"Linux"}
for example, how to judge whether the length of JSON reaches three. If only MCVersion,JavaVersion lacks Server, it indicates that JSON is incomplete. How to implement
{"MCVersion":"v1.10.0","JavaVersion":"v1.8","Server":"Linux"}
json object is the structure of a class array, and the sizeof function can be used to determine the length
.$data1=json_decode('{"MCVersion":"v1.10.0","JavaVersion":"v1.8","Server":"Linux"}', true);
var_dump($data1);
echo sizeof($data1);
will output
array(3) {
["MCVersion"]=>
string(7) "v1.10.0"
["JavaVersion"]=>
string(4) "v1.8"
["Server"]=>
string(5) "Linux"
}
3
Note that the second parameter of json_decode will return array type if you want to use true,. You can use sizeof, otherwise it will return stdClass.
Previous: How to catch an exception in vuex in vue2.x?
Next: Composer uses psr-4 to automatically load classes, why can't you find them?
I use php curl to retrieve json data from http , and then I use foreach array to display all the data , but when I encounter a problem, how to break it down? what kind of data does the counterparty need to give me? for example, he has a total of 30 yu...
I now need to write an api is a specific account where other people can upload videos to my server , but I don t know how to start? The concept of is that the counterpart can send the film to me through enctype= "multipart form-data " . I will sen...
< H2 > how did the printed index max item come from < H2 >? ...
<?php $a = [ name , age ]; var_dump( json_encode($a)); the result is [ "name ", "age "] this is a json data is fine, but what is returned is a json collection and what I need is a json object, I expect the following result { "na...
it is too large to read the json string from the json file to find the best solution directly by json_decode, ...
want to know how to add to the specified object in the document eg: after generating a set of json and adding it to the specified sncode.json using file_put_contents. {"sncode":[ {"model":"666","sncode":&qu...
hi, friends in this service I get output, but I think different outputs let me explain $customer_id = $_POST[ customer_id ]; $response = array(); $qry="SELECT category FROM nesbaty_customer where c_id= ".$customer_id." "...
{"returnCode":"0","resultCode":"0","amount":1.00} $param= {"returnCode":"0","resultCode":"0","amount":1.00} ; $param=json_decode($param,true); defau...
Today, when I transferred to the public api website of a trading station, the opposite side returned this format. I have never encountered it. Baidu is less than. I would like to ask which god has seen it. Can you explain it? 107:42["chartdata WTH...
this is the result of the query this is the php query code SELECT FROM_UNIXTIME(add_time, %Y-%m-%d ) as add_time, count(view_id) as viewTime FROM `view` GROUP BY `add_time` this is the whole php code header( Content-type: application j...
topic description I want to get information through the json of the website. I don t know why I can t get it. It s normal that the json URL has been tested. Do you guys help me to study the code to see what s wrong? sources of topics and their o...
php query to get an array, and then you need to use this array to write the json interface. Interface format: [ { "id": 4, "name": "", "open": false, "children": [ {...
this is the json structure of Fang Hui this is my method if I want to show it <? foreach ($dataUserList->{ themes } as $key) { ?> <? foreach ($key->{ theme-participants } as $value) { ?> <?=$value->...