mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
_check_count
This commit is contained in:
@@ -1112,19 +1112,19 @@ class parseCSV {
|
|||||||
* @return special string used for delimiter selection, or false
|
* @return special string used for delimiter selection, or false
|
||||||
*/
|
*/
|
||||||
protected function _check_count ($char, $array, $depth, $preferred) {
|
protected function _check_count ($char, $array, $depth, $preferred) {
|
||||||
if ( $depth == count($array) ) {
|
if ($depth == count($array)) {
|
||||||
$first = null;
|
$first = null;
|
||||||
$equal = null;
|
$equal = null;
|
||||||
$almost = false;
|
$almost = false;
|
||||||
foreach( $array as $key => $value ) {
|
foreach ($array as $key => $value) {
|
||||||
if ( $first == null ) {
|
if ($first == null) {
|
||||||
$first = $value;
|
$first = $value;
|
||||||
}
|
}
|
||||||
elseif ( $value == $first && $equal !== false) {
|
elseif ($value == $first && $equal !== false) {
|
||||||
$equal = true;
|
$equal = true;
|
||||||
}
|
}
|
||||||
elseif ( $value == $first+1 && $equal !== false ) {
|
elseif ($value == $first+1 && $equal !== false) {
|
||||||
$equal = true;
|
$equal = true;
|
||||||
$almost = true;
|
$almost = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1132,10 +1132,10 @@ class parseCSV {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $equal ) {
|
if ($equal) {
|
||||||
$match = ( $almost ) ? 2 : 1 ;
|
$match = ($almost) ? 2 : 1;
|
||||||
$pref = strpos($preferred, $char);
|
$pref = strpos($preferred, $char);
|
||||||
$pref = ( $pref !== false ) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999' ;
|
$pref = ($pref !== false) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999';
|
||||||
|
|
||||||
return $pref.$match.'.'.(99999 - str_pad($first, 5, '0', STR_PAD_LEFT));
|
return $pref.$match.'.'.(99999 - str_pad($first, 5, '0', STR_PAD_LEFT));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user