Archive for July 14th, 2009

PHP — Basic email val­i­da­tion with RegEx

July 14th, 2009
<?php
/**
 *                             CODETREE
 *                      support@mycodetree.com
 *                      http://mycodetree.com
 *
*/

function validateEmail($email) {

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {

return false;
}

return true;

}

?>

Ryan’s Rec­om­mended appli­ca­tion of the month

July 14th, 2009

Each month I pick an appli­ca­tion that I have used per­son­ally and find to be of good value and use and then I spread it’s aware­ness here on The CodeTree!

This month’s pick is the “Toggl Timer” (http://www.toggl.com)

Logo

Now that I have been explor­ing dif­fer­ent avenues with The Code­Tree I haven’t been doing hard­core free­lanc­ing like I have in the past but when I did and on the occa­sions that I do, I find that the Tog­gle Timer is my best friend.  There is a small cost to use it’s full poten­tial and to use it in a team envi­ron­ment but for a sin­gle devel­oper that is just time-tracking projects, it is free.

I think the fea­ture I appre­ci­ate the most is the ‘less is more’ approach the it takes to the appli­ca­tion inter­face.  Toggl offers a range of report­ing options, client/project rela­tion­ship man­age­ment, task/project man­age­ment and a desk­top timer client!

I give Toggl 2 thumbs up!

PHP — Get string between two strings

July 14th, 2009
<?php
/**
 *                             CODETREE
 *                      support@mycodetree.com
 *                      http://mycodetree.com
 *
*/

function get_string_between($string, $start, $end){
$string = " " . $string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string, $end, $ini) – $ini;
return substr($string, $ini, $len);
}
echo get_string_between($fullstring, "[tag]", "[/tag]");
?>

PHP — incre­men­tal date list between two points in time

July 14th, 2009
<?php
/**
 *                             CODETREE
 *                       support@mycodetree.com
 *                       http://mycodetree.com
 *
*/

$startDate = array('06/30/2009', strtotime('June 30th 2009'));
$endDate = array('08/30/2009', strtotime('August 30th 2009'));
$inc = $startDate[1];
while ($inc < $endDate[1]) {
$inc = $inc + 604800;
$options[] = "<option value='" . date('Y/m/d', $inc) . "'>" . date('F jS, Y', $inc) . "</option>";
}
?>
<select name='date' id='date'>
<option value='<?=$startDate[0];?>'><?=date ('F jS, Y', $startDate[1]);?></option>
<?php
foreach ($options as $value) {
echo $value . "\n";
}
?>
<option value='<?=$endDate[0];?>'><?=date ('F jS, Y', $endDate[1]);?></option>
</select>