55502f40dc8b7c769880b10874abc9d0

hi, I'm a student and i create this function, he print an spanish format date.

<?php
function fecha ()
{
$vect=getdate();
$vect_dia=array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&#225;bado");
$vect_mes=array("Diciembre","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre");
return $vect_dia[$vect[wday]].", ".$vect[mday]." de ".$vect_mes[$vect[mon]]." de ".$vect[year];
}
echo fecha()."<br>";
?>

Refactorings

No refactoring yet !

D41d8cd98f00b204e9800998ecf8427e

Felix

November 14, 2007, November 14, 2007 12:27, permalink

No rating. Login to rate!
132a00e84e74c003f68311b39b28e969

Mlopez

December 22, 2007, December 22, 2007 02:56, permalink

No rating. Login to rate!

you can remove the "hoy es".

i'm a little rusty on my spanish but it works.

http://www.mspy2.com/spanish.php - a working test.
we will find out on january 1st if it completely works.

<?php
function fecha ()
{
$vect=getdate();
$vect_dia=array("Domingo","Lunes","Martes","Mi&eacute;rcoles","Jueves","Viernes","S&aacute;bado");
$vect_mes=array("empty","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
return $vect_dia[$vect[wday]].", ".$vect[mday]." de ".$vect_mes[$vect[mon]]." de ".$vect[year];
}
echo "Hoy es ".fecha()."<br>";
?>
1c79eae7e8565e8a59ccee357c32e658

Caco_Patane

March 18, 2009, March 18, 2009 20:31, permalink

No rating. Login to rate!

In the line containing the 'return' statement the indexes of the $vect array are referenced incorrectly as constants and must be referenced as string. For example, instead of $vect[wday] you must use $vect['mday'] or PHP will comply.

return $vect_dia[$vect['wday']].", ".$vect['mday']." de ".$vect_mes[$vect['mon']]." de ".$vect['year'];
6ff4b6b869f2436d040abd68cfa4496b

Vlad

August 25, 2010, August 25, 2010 20:22, permalink

No rating. Login to rate!

Thank you, it is working, perfectly.

F44b074e3f37878176e35f1f35e9069f

clonecd287

May 9, 2011, May 09, 2011 00:30, permalink

No rating. Login to rate!

Circumstances alter cases.

Your refactoring





Format Copy from initial code

or Cancel