Created
May 30, 2012 23:50
-
-
Save tamouse/2839634 to your computer and use it in GitHub Desktop.
response to https://gist.github.com/09cf0ba5a6f1f90620f5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(-1); | |
ini_set('display_errors',true); | |
ini_set('display_startup_errors',true); | |
function array_to_english ( $list, $glueword='and' ) { | |
$string = false; | |
foreach ( array_reverse ( $list ) as $index=>$value ) { | |
$string = "$value$glue$string"; | |
if ( $index == 0 ) $glue = " $glueword "; | |
if ( $index == 1 ) $glue = ', '; | |
} | |
return $string; | |
} | |
$a=array('one','two','three','last'); | |
echo array_to_english($a); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-*- mode: compilation; default-directory: "~/Projects/scratch/" -*- | |
Compilation started at Wed May 30 18:46:08 | |
php a2eng.php | |
PHP Notice: Undefined variable: glue in /Users/tamara/Projects/scratch/a2eng.php on line 12 | |
Notice: Undefined variable: glue in /Users/tamara/Projects/scratch/a2eng.php on line 12 | |
one, two, three and last | |
Compilation finished at Wed May 30 18:46:10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment