public static function formToBdd($mask, $values)
    {
        $parse   = self::parseChartMask($mask);
        $nbInput = count($parse);
        $value = '';
        foreach ($values as $row) {
            $value .= $row['value'];
        }
        if ($value == '') {
            return null;
        }
        if ($nbInput === 1) {
            return $values[0]['value'];
        }
        $value = '';
        for ($k = 0; $k <= $nbInput - 1; $k++) {
            $part   = $values[$k]['value'];
            $length = $parse[$k]['size'];
            if (strlen($part) < $length) {
                if ($k === 0) {
                    if ($part === '') {
                        $part = '0';
                    }
                } else {
                    if ($k === $nbInput - 1) {
                        $part = str_pad($part, $length, '0', STR_PAD_RIGHT);
                    } else {
                        $part = str_pad($part, $length, '0', STR_PAD_LEFT);
                    }
                }
            }
            $value .= $part;
        }

        return $value;
    }
public static function formToBdd($mask, $values)
    {
        $parse   = self::parseChartMask($mask);
        $nbInput = count($parse);
        $value = '';
        foreach ($values as $row) {
            $value .= $row['value'];
        }
        if ($value == '') {
            return null;
        }
        if ($nbInput === 1) {
            return $values[0]['value'];
        }
        $value = '';
        for ($k = 0; $k <= $nbInput - 1; $k++) {
            $part   = $values[$k]['value'];
            $length = $parse[$k]['size'];
            if (strlen($part) < $length) {
                if ($k === 0) {
                    if ($part === '') {
                        $part = '0';
                    }
                } else {
                    if ($k === $nbInput - 1) {
                        $part = str_pad($part, $length, '0', STR_PAD_RIGHT);
                    } else {
                        $part = str_pad($part, $length, '0', STR_PAD_LEFT);
                    }
                }
            }
            $value .= $part;
        }

        return $value;
    }
public static function formToBdd ( $ mask , $ values ) { $ parse = self :: parseChartMask ( $ mask ) ; $ nbInput = count ( $ parse ) ; $ value = '' ; foreach ( $ values as $ row ) { $ value .= $ row [ 'value' ] ; } if ( $ value == '' ) { return null ; } if ( $ nbInput === 1 ) { return $ values [ 0 ] [ 'value' ] ; } $ value = '' ; for ( $ k = 0 ; $ k <= $ nbInput - 1 ; $ k ++ ) { $ part = $ values [ $ k ] [ 'value' ] ; $ length = $ parse [ $ k ] [ 'size' ] ; if ( strlen ( $ part ) < $ length ) { if ( $ k === 0 ) { if ( $ part === '' ) { $ part = '0' ; } } else { if ( $ k === $ nbInput - 1 ) { $ part = str_pad ( $ part , $ length , '0' , STR_PAD_RIGHT ) ; } else { $ part = str_pad ( $ part , $ length , '0' , STR_PAD_LEFT ) ; } } } $ value .= $ part ; } return $ value ; }
Transform values to insert database

@param string $mask
@param array $values

@return string
Transform values to insert database