Archive for the ‘Eco friendly / green computing’ Category

To reset the key values in a PHP array you can do this:
1234567891011121314151617181920212223$things = array(’a',’b',’c',’d');
unset($things[0]);
print_r($things);

#outputs
#Array
#(
#    [1] => b
#    [2] => c
#    [3] => d
#)

# Actually do the reset.
$things = array_values($things);

print_r($things);
#outputs
#Array
#(
#    [0] => b
#    [1] => c
#    [2] => d
#)

Ran into an interesting situation yesterday. I wanted to create some dynamic (overloading) object attributes (object member variables) in PHP with private visibility. Forcing encapsulation via getter methods. It seems this is not possible, as dynamic attributes are only ever public (see the PHP documentation).
There is however, as always, a work around! If you [...]

Today I had a log table report query that contained a nested query. It was taking ages (5mins) to complete. I investigated indexes which I had been meaning to look at for a while. Anyway I managed to bring down the query to 0.04s – I now have much love for indexes!!
Basic MySQL syntax:
1CREATE INDEX [...]

A little off topic but hey it does say ‘& stuff’ in the Blog title!
I’m turning into a bit of an energy conservationalist, if there’s such a word!
I was dong a bit of reading about energy efficient power supply units for PC’s. I suddenly thought about the cheap 350w Jeantech unit I had in my [...]


top