Toolbox::cleanInteger PHP Méthode

cleanInteger() static public méthode

Clean integer value (strip all chars not - and spaces )
static public cleanInteger ( $integer ) : clean
$integer string integer string
Résultat clean integer
    static function cleanInteger($integer)
    {
        return preg_replace("/[^0-9-]/", "", $integer);
    }

Usage Example

Exemple #1
0
 function prepareInputForAdd($input)
 {
     // Clean values
     $input['tickets_id_1'] = Toolbox::cleanInteger($input['tickets_id_1']);
     $input['tickets_id_2'] = Toolbox::cleanInteger($input['tickets_id_2']);
     // Check of existance of rights on both Ticket(s) is done by the parent
     if ($input['tickets_id_2'] == $input['tickets_id_1']) {
         return false;
     }
     if (!isset($input['link'])) {
         $input['link'] = self::LINK_TO;
     }
     // No multiple links
     $tickets = self::getLinkedTicketsTo($input['tickets_id_1']);
     if (count($tickets)) {
         foreach ($tickets as $key => $t) {
             if ($t['tickets_id'] == $input['tickets_id_2']) {
                 // Delete old simple link
                 if ($input['link'] == self::DUPLICATE_WITH && $t['link'] == self::LINK_TO) {
                     $tt = new Ticket_Ticket();
                     $tt->delete(array("id" => $key));
                 } else {
                     // No duplicate link
                     return false;
                 }
             }
         }
     }
     return parent::prepareInputForAdd($input);
 }
All Usage Examples Of Toolbox::cleanInteger