PHP Json Help

Started on the old forum in December 2012 · view the original in the archive · old links redirect here

3 replies · 1,293 views · started 13 years ago · 1 min read

3 participants
Christian Cepe Newbie · 7 posts #1

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)

{
   "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 🙂

kevk3v Senior · 332 posts #2

Well i dont know json but u can try this loll...

<?php

$json = file_get_contents("path to json file");

$uid = explode('"uid2": "',$json);

$i=0;
while($i<=9)

  {
  echo array_rand($uid).'<br/>';
  $i++;
  }

?>

Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

Christian Cepe Newbie · 7 posts #3

kevk3v wrote: Well i dont know json but u can try this loll...

<?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..

something else Fellow · 2,296 posts #4
function randomOrder()
{
    return (Math.round(Math.random())-0.5); 
}

data.sort(randomOrder);

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close