Archive for the ‘code’ Category
Automatically update the copyright on your website with PHP
This is one of those little things you always forget, probably because it’s so small and insignificant.
Did you ever have a client call or e-mail you with the question to update the copyright on the website you created for them last year? I know I have had those questions from clients (rightly so).
With this little code snippet you’ll never have to worry about it again.
Place this somewhere in your functions.php (or whatever you named it):
<?php
function printCopyright($startyear) {
$currentyear = date(Y);
if ($startyear == $currentyear) {
echo 'Copyright © '. $startyear;
}
else {
echo 'Copyright © '. $startyear .' - '. $currentyear;
}
}
?>
Once that is in your functions.php you can just use this: <?php printCopyright(2010); ?> in your template where you want your copyright to be printed. It takes one parameter, the year you want your copyright to start or has started.
If the current year is also the year your copyright started, then it will return “Copyright © 2010″ and if your copyright started earlier (let’s say in 2007), then it will return “Copyright © 2007 – 2010″.
How to remove an element from an array
Soo, I’m learning more and more php these days and today I stumbled onto a problem, which I couldn’t solve myself.
How do you remove an element from an array in php?
After a quick google search I found this:
foreach($array as $key => $value) {
if($value == "" || $value == " " || is_null($value)) {
unset($array[$key]);
}
}
/*
and if you want to create a new array with the keys reordered accordingly
*/
$new_array = array_values($array);
Tnx to Scriptygoddess
This works okay, but I’m wondering if this is the best/quickest way to remove an element from an array?
And isn’t there a built-in function in php that does the same thing?
Linkypoo 20 mei 2005
- Experiment with position:fixed
Zo simpel en toch zo effectief. Lees ook: Comments: Behind the Scenes. - Your Google Homepage
Ben er nog niet uit, wat ik hiervan moet vinden. - How To Disable GreaseMonkey On Your Web Site
“After installing GreaseMonkey I noticed that some of my code samples were completely broken in Firefox.”
Linkypoo 13 mei 2005
- min-width for IE
Simpel en het werkt ook nog (voor zover ik heb kunnen testen :) - mod_rewrite Cheat Sheet
Na de php en css cheat sheets, is er nu ook de mod_rewrite Cheat Sheet
CSSVault verkocht
Scrivs heeft de CSSVault verkocht.
De CSSVault is toch een soort van instituut geworden in het promoten van web standards en design.
Het is jammer dat het verkocht is en de vraag is hoe het er in de toekomst uit gaat zien. De nieuwe eigenaar zegt dat er weinig zal veranderen. We zullen zien.
Maar voor dat geld ($XX,XXX) had ik het ook gedaan :)
Linkypoo 24 november 2004
- How to do vertically en horizontally scalable edges?
De vraag - Scalable rounded edges
De oplossing - Mammografie geeft uitsluitsel
Ze zijn dus echt.
CSS achtergrond afbeelding in Safari
Aangezien ik zelf geen Mac tot m’n beschikking heb, is het handig om dingen als dit bij de hand te houden.