# \[PHP\] search db or files?

**URL:** <https://forum.kirupa.com/t/php-search-db-or-files/42126>\
**Category:** Uncategorized\
**Created:** [February 5, 2004, 3:02pm UTC](https://forum.kirupa.com/t/php-search-db-or-files/42126 "2004-02-05T15:02:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koorb](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/koorb/32/424_2.png) [@koorb](https://forum.kirupa.com/u/koorb)\
**Post date:** [February 5, 2004, 3:02pm UTC](https://forum.kirupa.com/t/php-search-db-or-files/42126/1 "2004-02-05T15:02:01Z")

</div>

So im wondering, for my next project I was going to use XML files to store the data, but I want the site to be able to search what would be in the \<content\> tag. Would it be wiser to use a database rather than XML, which would envolve opening the xml file, parsing it then working out if the `needle` is in the content?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 3:09pm UTC](https://forum.kirupa.com/t/php-search-db-or-files/42126/2 "2004-02-05T15:09:58Z")

</div>

Well the XML would require more scripting but its not in any way more difficult or intensive. I prefer to use both. Keep everything in a database and then output that data as XML that way I can use XML when I need it and just use the straight Database when I need to…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 5, 2004, 3:10pm UTC](https://forum.kirupa.com/t/php-search-db-or-files/42126/3 "2004-02-05T15:10:06Z")

</div>

Well, with XML you would either have to create your own search function or have some server-side program do it for you. Databases usually have their own search functions you can use, and some of the time, implement a more efficient method.
