There are a lot of general practices in programming theory one can make use of to make things more efficient or just possible.
Of particular interest are php tips but something that carries over across languages would be pretty handy too.
Here's a technique that came to me as soon as I read the page for explode() on php.net. I've seen some code with data storage limitations that obviously does not use this technique for storing data that is extremely handy, if not always easy to access. Maybe someone out there will find this useful. Chances are, if you're reading this you're already motivated enough to learn that you already know it, in which case I hope you'll also share a useful technique.
Stick different data in one string instead of separate fields. This saves database queries and overhead because instead of 10 int fields you can have one varchar that holds ten ints separated by a delimiter. When I want to manage the string with str_replace(), the lazy way to do it, I would use '|' or something as a delimiter and store strings like this:
$str = '1244|1245|1320|';
Then split the string with explode()
$arr = explode('|', $str);
In the case of SQL queries I've frequently stored IDs in this way. Once you have the IDs in an array I build a query with them.
$where = '';
foreach ($arr as $id) {
$where .= " id=$id OR";
}
$where = substr($where, 0, -3);
mysql_query("SELECT * FROM table WHERE $where");
That's it for me. So.. does anyone have a fancier way of efficiently storing similar data or a useful algorithm or anything? I always want to learn more.