484 CHAPTER 20 WEB SERVICES Figure 20-3.

484 CHAPTER 20 WEB SERVICES Figure 20-3. Aggregating feeds Although the use of a static array for containing feeds certainly works, it might be more practical to maintain them within a database table, or at the very least a text file. It really all depends upon the number of feeds you ll be using, and how often you intend on managing the feeds themselves. Limiting the Number of Displayed Headlines Some Web site developers are so keen on RSS that they wind up dumping quite a bit of information into their published feeds. However, you might be interested in viewing only the most recent items, and ignoring the rest. Because Magpie relies heavily on standard PHP language features such as arrays and objects for managing RSS data, limiting the number of headlines is trivial, because you can call upon one of PHP s default array functions for the task. The function array_slice() should do the job quite nicely. For example, suppose you want to limit total headlines displayed for a given feed to three. You can use array_slice() to truncate it prior to iteration, like so: $rss->items = array_slice($rss->items, 0, 3); Revising the previous script to include this call results in output similar to that shown in Figure 20-4.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Leave a Reply