PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I need to save name="home" to a string and pagetitle="Home" to a string, but I just need the contents of those, not the quotes and stuff. I'm creating my own format for storing information for a php script I'm making, but the code I displayed above CAN vary, causing the need to look for name=" and to start saving info to the string after the first quote, and to stop at the second quote, the same for pagetitle="". So, how do I do this? Since I am bad at explaining, this is the output I want:
I only want the first match, yours provides multiple matches if applicable, right?
I also can't just look for <data type="page" name="home" pagetitle="Home", because the way my script is going to work is that when someone goes to index.php?p=home, it's going to read the data file and look for <data type="page" name="$p"...
and it's going to need to save pagetitle's contents to a string, it will also look for the data after the data element and save it into a string and stop saving when it reaches </data>
I forgot to ask the whole question in the first post, it was too much for me to think about then, since I am bad at explaining usually.
Last edited by toasty2 on Sat Aug 12, 2006 11:14 am, edited 1 time in total.
I might try that, the data element I made has the actual page's contents saved between <data> and </data>, it's for a CMS. I was going to make my own format, because I'm not that knowledgeable on xml, each page in my CMS is going to have a <data type="page" name="name_of_page" pagetitle="the title of the page">The contents of the page go here</data>, so I have a question...do I make each page be inside it's own <dataset> </dataset> elements, or do I do like this?
<dataset>
<data type="page" name="home" pagetitle="Welcome to our homepage">Page contents go here</data>
<data type="page" name="stuff" pagetitle="Stuff">Here is random stuff</data>
</dataset>
Aside from simplicity, why? What's wrong with one file? I was thinking it would be easier to manage, and to back it up if it was in one file, but I do wonder, what happens if the file gets really huge? Will php take really long to do stuff to it or read it?
Say, for instance, you have ten pages. Assume each page has two to three kilobytes of text. That's 30K of page data for PHP to load plus the overhead of parsing the XML to find only 3K from it. Now consider having 100 pages.
Shall we say a single file has diminishing returns? Yes. Is a single file easier to manage? Maybe. Is a single file modular? It has some modularity, but not all that much. Is multiple files modular? More often, yes. If you could have several people updating pages at once, it's much better to have separate files. With possible growth of a site in mind, it's likely that there would be multiple editors.
And there won't be multiple people editing pages with this cms, but the multiple files idea is still better. Also, in my hunt to think of ways to avoid using databases, I've thought of a secure way to store user data (inside a php file):
Um, I'm finally trying out your code, but there's one problem, you can input the text to look for and get the output, but what string is it supposed to search in? If I can't specify the source, how am I going to search it?