Pair ou Impair ?
if ($nombre%2 == 0) {
// pair
}
else {
// impair
}
[source]
if ($nombre%2 == 0) {
// pair
}
else {
// impair
}
[source]
function un_microsuck($text){
static $chars = array(
128 => '€', 130 => '‚', 131 => 'ƒ',
132 => '„', 133 => '…', 134 => '†',
135 => '‡', 136 => 'ˆ', 137 => '‰',
138 => 'Š', 139 => '‹', 140 => 'Œ',
142 => 'Ž', 145 => '‘', 146 => '’',
147 => '“', 148 => '”', 149 => '•',
150 => '–', 151 => '—', 152 => '˜',
153 => '™', 154 => 'š', 155 => '›',
156 => 'œ', 158 => 'ž', 159 => 'Ÿ'
);
$text = str_replace(array_map('chr', array_keys($chars)), $chars,
$text);
return $text;
}
Note : fonction copiée-collée d'ici et pas encore testée.
<?php
$uploaddirectory = "upload/";
$photo = $_FILES['photo'];
if($photo['tmp_name'] != null)
{
$nom_photo = date("Y-m-d-H-i-s").".jpg";
$destination = $uploaddirectory.$nom_photo;
if($photo['type'] != "image/jpeg")
{ die("Pas la bonne extension"); }
elseif( !@is_uploaded_file($photo['tmp_name']) )
{ die("Upload erreur"); }
elseif (!@move_uploaded_file($photo['tmp_name'], $destination) )
{ die("Move erreur"); }
else
{ echo '<p>Upload ok de la photo : <img src="'.$uploaddirectory.$nom_photo.'"></p>'; }
}
?>
<form action="upload.php" enctype="multipart/form-data" method="post">
<input type="file" name="photo"/>
<input type="submit" value="upload"/>
</form>
$caracteres = "0123456789";
if (strspn($variable, $caracteres) < strlen($variable))
{ $result = "Il y a des caractères interdits"; }