rarebit Posted June 11, 2008 Share Posted June 11, 2008 Hi, i've got a list of 2800 elements in a db table, this is used to generate a form select. This is fine, but it can be a bit slow in realty. Therefore i'm wanting to cache it, no problem, until I think as to how to change the default selected element. I've either got to regenerate the list, or the only other thing I can think of is regex, arhh, actually 'str_replace' will probably be best... Anyone any other suggestions? Link to comment https://forums.phpfreaks.com/topic/109787-solved-cache-prob/ Share on other sites More sharing options...
btherl Posted June 12, 2008 Share Posted June 12, 2008 You could cache the data as an array after fetching from the database. That eliminates the database access, though not the generation of the list. But for what you're doing I think a str_replace() would work just fine. Another option is you can cache an array of lines of html. Then to set option #2453, you just edit line 2452 of the array (1 less because arrays usually start at 0). Link to comment https://forums.phpfreaks.com/topic/109787-solved-cache-prob/#findComment-563555 Share on other sites More sharing options...
rarebit Posted June 12, 2008 Author Share Posted June 12, 2008 Cheers, i've gone for the str_replace method and added some extras (name, title, width, extras) and it seems to work fast enough... Link to comment https://forums.phpfreaks.com/topic/109787-solved-cache-prob/#findComment-564150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.