Archive for April 26th, 2006

On the note of arrays… Building large MSQL inserts with php, the easy way


26 Apr
  • $cols[0] = “title”;
  • $vals[0] = “”CodeWord: Apoalyptik”";
  • $cols[1] = “url”;
  • $vals[1] = “”http://blog.apokalyptik.com/”";
  • $cols[2] = “feed_url”
  • $vals[2] = “”http://blog.apokalyptik.com/?feed=rss2″”;

$query=”INSERT INTO weblogs (“.implode(“,”, $cols).”) VALUES(“.implode(“,”, $vals).”)”;

This might be of use to someone


26 Apr

I’ve been writing PHP for a long time now. And one of the things that I see quite often is that people just dont get multidimensional arrays, and how to effectively store data in them for looping. Allow me to lead by example.

  • $store['fruit']['apple']=3;
  • $store['fruit']['orange']=1;
  • $store['berries']['blueberries']=100;
  • $store['berries']['strawberries']=100;
  • $store['fruit']['mango']=5;
  • foreach ( $store as $type => $val ) {
    • foreach ( $val as $name => $qty ) {
      • echo “We have {$qty} {$name} ({$type} are good for you)rn”;
    • }
  • }

of course where the array comes from and what you do with it are completely optional. But it’s important to know that the array indexes should be as informational as the array values. Otherwise you arent using arrays properly.

Link Blogging 04.26.06


26 Apr

Eye-Fi — Frickin cool!

CleverSafe (Slashdot Article) — About time someone thought “hey, parity, back, WHOA!”…

Patent Trolls — ICK ACK FOO BAR GRRR

Order of the stick — I havent played D&D for, must be 10 years now… and I still find this strip funny on a regular basis… (though if you’ve never played dont bother… it wont make sense)

CodeWord: Apokalyptik

The random things that spew forth from my brain…