note 17644 deleted from ref.strings by jimw

From: Date: Fri, 21 Dec 2001 00:37:46 +0000
Subject: note 17644 deleted from ref.strings by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23652@lists.php.net to get a copy of this message
I had some problems with a database that returned the days in this format: montuewed... (but in portuguese). So I made a function that splits up the word returning only mon or tue. Maybe useful for the ones who receive a whole string, without spaces or dots and need to add a char or parse the string. function day_day($day) { $dias = array ( "dom" => "Domingo", "seg" => "Segunda", "ter" => "Terça", "qua" => "Quarta", "qui" => "Quinta", "sex" => "Sexta", "sab" => "Sábado"); while (list($key, $val) = each($dias)) { if ($day == $key) return $val; } } function day($day) { if (strlen($day) < 3) return -1; for ($i = 0; $i != strlen($day); $i += 3) { $actual = substr($day, $i-strlen($day), 3); $final .= $this->day_day($actual)." "; } return $final; }

« previous php.notes (#23652) next »