strzlee / JsonDB.class.php

JSON Databaseclass. Handle JSON-Files like a very, very simple DB.
Do What The F*ck You Want To Public License
93 stars 47 forks source link

Select where item is in array #13

Open jeyemwey opened 9 years ago

jeyemwey commented 9 years ago

I got the following table with blog posts:

[  
  {  
    "title": "A post",
    "slug": "a-post",
    "content": "...Lorem ipsum dolor sit amet, consectetur adipisicing...",
    "tags": [  
      "Android",
      "App Tipp",
      "Twitter"
    ]
  },
  {  
    "title": "Another post",
    "slug": "another-post",
    "content": "...ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderi...",
    "tags": [  
      "Android",
      "App Tipp"
    ]
  }
]

For my application, I'd like to select any post that has the tag "Twitter" (or anything else). Since I have several hundreds of sets, I do not want to select all and ask each one of the posts if they had this tags..

Can you build a method that looks for array items?