PHP Json Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP Json Help

    Help me please. Here is what the output must --> In a one page of .php it will display 10 uids and it will be randomly.. example ..

    1047248466
    100000843854054
    100000158047683
    100000687987446
    100000623095471

    here is the Json. (fbgraph)
    PHP Code:
    {
       "data": [
          {
             "uid2": "1047248466"
          },
          {
             "uid2": "100004174328801"
          },
          {
             "uid2": "721364208"
          },
          {
             "uid2": "100001334165161"
          },
          {
             "uid2": "100000843854054"
          },
          {
             "uid2": "100000719683265"
          },
          {
             "uid2": "100000823284097"
          },
          {
             "uid2": "100000365176220"
          },
          {
             "uid2": "739100179"
          },
          {
             "uid2": "100000158436986"
          },
          {
             "uid2": "100001612411878"
          },
          {
             "uid2": "100000485832177"
          },
          {
             "uid2": "100001028859754"
          },
          {
             "uid2": "100003000658260"
          },
          {
             "uid2": "100000158047683"
          },
          {
             "uid2": "100000831320562"
          },
          {
             "uid2": "100004273121987"
          },
          {
             "uid2": "100000536192614"
          },
          {
             "uid2": "100000189294735"
          },
          {
             "uid2": "100000995375807"
          },
          {
             "uid2": "100000187505659"
          },
          {
             "uid2": "100003120030651"
          },
          {
             "uid2": "100000070704603"
          },
          {
             "uid2": "100000687987446"
          },
          {
             "uid2": "100002317991626"
          },
          {
             "uid2": "100000623095471"
          },
          {
             "uid2": "100000355495487"
          },
          {
             "uid2": "100001879698767"
          }
       ]
    } 
    
    Thanks
    Last edited by metulj; 13.12.12, 16:04. Reason: use [php] or [code] tag when posting code

    #2
    Well i dont know json but u can try this loll...
    PHP Code:
    
    <?php
    
    $json = file_get_contents("path to json file");
    
    $uid = explode('"uid2": "',$json);
    
    $i=0;
    while($i<=9)
    
      {
      echo array_rand($uid).'<br/>';
      $i++;
      }
    
    ?>
    Last edited by kevk3v; 13.12.12, 15:57.
    Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

    Comment


      #3
      Originally posted by kevk3v View Post
      Well i dont know json but u can try this loll...
      PHP Code:
      
      <?php
      
      $json = file_get_contents("path to json file");
      
      $uid = explode('"uid2": "',$json);
      
      $i=0;
      while($i<=9)
      
        {
        echo array_rand($uid).'<br/>';
        $i++;
        }
      
      ?>
      its not working..

      Comment


        #4
        PHP Code:
        function randomOrder()
        {
            return (Math.round(Math.random())-0.5); 
        }
        
        data.sort(randomOrder); 
        

        Comment

        Working...
        X