Jump to content

lufa20

Members
  • Posts

    4
  • Joined

  • Last visited

lufa20's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Everything works when I assigned JSON variable into a string manually, but when I tried to read JSON variable from a file nothing shows up. Why? WORKS $string= json_decode('{"RubricCriterion":[{"num":1,"value":"0","previous_version":null,"position":1,"name":"Writing","description":"Grammar, spelling, sentence structure, organization, clarity\n\n\n\n25","rubric":352226,"criterion_scales":[10970777,10970781,10970785,10970789],"id":3420113},{"num":2,"value":"0","previous_version":null,"position":2,"name":"APA","description":"APA Style in paper narrative and references\n\n\n20","rubric":352226,"criterion_scales":[10970778,10970782,10970786,10970790],"id":3420114},{"num":3,"value":"0","previous_version":null,"position":3,"name":"References","description":"Quality of references is scholarly, current or classic references included; wide variety of primary sources\n\n10","rubric":352226,"criterion_scales":[10970779,10970783,10970787,10970791],"id":3420115},{"num":4,"value":"0","previous_version":null,"position":4,"name":"Framework","description":"Relation to............and so on Doesn't Work $file = "MyRubric.rbc"; $string= json_decode(file_get_contents($file, true)); echo file_get_contents($file); {"RubricCriterion":[{"num":1,"value":"0","previous_version":null,"position":1,"name":"Writing","description":"Grammar, spelling, sentence structure, organization, clarity\n\n\n\n25","rubric":352226,"criterion_scales":[10970777,10970781,10970785,10970789],"id":3420113},{"num":2,"value":"0","previous_version":null,"position":2,"name":"APA","description":"APA Style in paper narrative and references\n\n\n20","rubric":352226,"criterion_scales":[10970778,10970782,10970786,10970790],"id":3420114},{"num":3,"value":"0","previous_version":null,"position":3,"name":"References","description":"Quality of references is scholarly, current or classic references included; wide variety of primary sources\n\n10","rubric":352226,"criterion_scales":[10970779,10970783,10970787,10970791],"id":3420115},{"num":4,"value":"0","previous_version":null,"position":4,"name":"Framework","description":"Relation to ...... and so on I am thinking it has to do with the beginning of the file junk stuff, though none show in notepad. Any way I can target/skip to JSON variable for reading?
  2. why does it work when I insert it into $string and it doesn't when I don't <? $file = "rbc/$_GET[parse]"; $string = json_decode(file_get_contents($file, true)); foreach ($string->RubricCriterion as $rubric) { echo $rubric->name; } ?> EDIT [ignace]: I accidently edited your post mistaken it for quoting you so the wording may be different, my apologies
  3. Ok here is what I have and what I need it to look like: Sample file: Desired Output (i will format the html to make it pretty)
  4. I am looking for a way to parse a file that contains a lot of text that is comma separated, yet it is not a csv. What i want is to find a keyword then echo that keyword and a few characters after that keyword, then look for another keyword and echo that keyword and some characters after that keyword...etc. Can someone point me in the right direction please?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.