Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Outlook
/
Fusion
/
Table
:
test_valeur_02.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php $array_val = array(" 51 78 ", "78&7", "747Z", "747z", "1747", ".1792.AqP.44." , "AZerTY", "8.15", "123.78.94" , ".514" , "357."); $array_process = array(); echo "<pre>"; print_r($array_val); echo "</pre>"; for ($i = 0; $i < count($array_val); $i++) { $array_val[$i] = preg_replace("/[^0-9.]/", "", $array_val[$i]); } echo "<pre>"; print_r($array_val); echo "</pre>"; for ($i = 0; $i < count($array_val); $i++) { // si la chaine est vide, cela siginifie qu'il n'y avait que des lettres if( strlen($array_val[$i]) == 0 ) { $array_process[$i] = "vide"; } else { $pieces = str_split($array_val[$i]); // compter les points $test = point_exploration($pieces); // non valide car plusieurs points if( $test == true) { $array_process[$i] = "vide"; } // il y a un seul point else { // supprimer le point en premiére position if( $pieces[0] == chr(46) ) { $changed = substr($array_val[$i], 1); $array_process[$i] = $changed; } // supprimer le point en derniere position else if( end($pieces) == chr(46) ) { $changed = substr($array_val[$i], 0, -1); $array_process[$i] = $changed; } // on conserve le point qui défini un nombre decimal else { $array_process[$i] = $array_val[$i]; } } } } echo "<pre>"; print_r($array_process); echo "</pre>"; function point_exploration($pieces) { $cpt = 0; $flag_not_valide_point = false; for ($i = 0; $i < count($pieces); $i++) { if( $pieces[$i] == chr(46) ) { // compte les points qui sont inclus dans la chaine $cpt++; if( $cpt >= 2 ) { $flag_not_valide_point = true; break; } } } return $flag_not_valide_point; } ?>