src/bbn/x.php
public static function to_keypair($arr, $protected = 1){
    $num = \count($arr);
    $res = [];
    if ( ($num % 2) === 0 ){
      $i = 0;
      while ( isset($arr[$i]) ){
        if ( !\is_string($arr[$i]) || ( !$protected && !preg_match('/[0-9A-z\-_]+/8', str::cast($arr[$i])) ) ){
          return false;
        }
        $res[$arr[$i]] = $arr[$i+1];
        $i += 2;
      }
    }
    return $res;
  }
public static function to_keypair($arr, $protected = 1){
    $num = \count($arr);
    $res = [];
    if ( ($num % 2) === 0 ){
      $i = 0;
      while ( isset($arr[$i]) ){
        if ( !\is_string($arr[$i]) || ( !$protected && !preg_match('/[0-9A-z\-_]+/8', str::cast($arr[$i])) ) ){
          return false;
        }
        $res[$arr[$i]] = $arr[$i+1];
        $i += 2;
      }
    }
    return $res;
  }
public static function to_keypair ( $ arr , $ protected = 1 ) { $ num = \ count ( $ arr ) ; $ res = [ ] ; if ( ( $ num % 2 ) === 0 ) { $ i = 0 ; while ( isset ( $ arr [ $ i ] ) ) { if ( ! \ is_string ( $ arr [ $ i ] ) || ( ! $ protected && ! preg_match ( '/[0-9A-z\-_]+/8' , str :: cast ( $ arr [ $ i ] ) ) ) ) { return false ; } $ res [ $ arr [ $ i ] ] = $ arr [ $ i + 1 ] ; $ i += 2 ; } } return $ res ; }
Converts a numeric array into an associative one, alternating key and value.

```php
\bbn\x::to_keypair(['Test', 'TestFile', 'Example', 'ExampleFile']);
// string ['Test' => 'TestFile', 'Example' => 'ExampleFile']
```

@param array $arr The array. It must contain an even number of values
@param bool $protected If false no index protection will be performed
@return array|false
Converts a numeric array into an associative one alternating key and value .