Qbot industries Qbot industries - 4 months ago 7x
JSON Question

How can i check if shape:[] is null in json with php

I have a json object like this :


How can I check if the array Shape:[] is empty with PHP I only know how to do it with JavaScript but this matter needs PHP to be used how can I do it?


You can use json_decode() and then access it's members.

$json = json_decode('{"Techne":{"@Version":"2.2","Author":"ZeuX","Name":"","PreviewImage":"","ProjectName":"","ProjectType":"","Description":"","DateCreated":"","Models":[{"Model":{"GlScale":"1,1,1","Name":"","TextureSize":"1,1","@texture":"texture.png","BaseClass":"ModelBase","Geometry":{"Folder":[],"Shape":[],"Piece":[],"Null":[]}}}]}}');

    echo "Shape is empty";

json_decode() will give you an object in this case, because that is how this JSON string is formatted. You can learn more by searching about JSON and PHP, there are plenty of tutorials that will help you understand better.

I hope it helped you.