There is such a text in json :

 "tasks":[{"id":3,"target":320,"progress":0,"description":1},{"id":2,"target":3,"progress":0,"description":1},{"id":15,"target":4,"progress":0,"description":5},{"id":16,"target":3,"progress":0,"description":1},{"id":17,"target":5,"progress":0,"description":4},{"id":18,"target":2,"progress":0,"description":1},{"id":19,"target":1,"progress":0,"description":0},{"id":21,"target":3,"progress":0,"description":1}] 

How to get this:

 $zID1 = '3'; $zID2 = '2'; $zID3 = '15'; $zID4 = '16'; $zID5 = '17'; $zID6 = '18'; $zID7 = '19'; $zID8 = '21'; 

    1 answer 1

    something like this:

     $zID = array(); $a = json_decode($json, TRUE); for($i=0; $i < count($a['task']); $i++) $zID[] = $a['tasks'][$i]['id']; var_dump($zID); 
    • extract ($ zID); Quotation after id - vkovalchuk88
    • I fixed the quote, thanks - deivan_
    • For some reason, the elements after this code do not work. - Glory to Gesto
    • $ zID is an array, its elements should be accessed as $ zID [0], $ zID [1], ... - deivan_
    • I understood that, but after these lines, the code that comes after does not work - Slava Gesto