src/bbn/str.php
public static function correct_types($st){
    if ( \is_string($st) ){
      if ( self::is_buid($st) ){
        $st = bin2hex($st);
      }
      else{
        if ( self::is_json($st) ){
          if ( strpos($st, '": ') && ($json = json_decode($st)) ){
            return json_encode($json);
          }
          return $st;
        }
        $st = trim($st);
        // Not starting with a zero or ending with a zero decimal
        if ( !preg_match('/^0[^.]+|\.[0-9]*0$/', $st) ){
          if ( self::is_integer($st) && ((substr((string)$st, 0, 1) !== '0') || ($st === '0')) ){
            $tmp = (int)$st;
            if ( ($tmp < PHP_INT_MAX) && ($tmp > -PHP_INT_MAX) ){
              return $tmp;
            }
          }
          // If it is a decimal, not starting or ending with a zero
          else if ( self::is_decimal($st) ){
            return (float)$st;
          }
        }
      }
    }
    else if ( \is_array($st) ){
      foreach ( $st as $k => $v ){
        $st[$k] = self::correct_types($v);
      }
    }
    else if ( \is_object($st) ){
      $vs = get_object_vars($st);
      foreach ( $vs as $k => $v ){
        $st->$k = self::correct_types($v);
      }
    }
    return $st;
  }
public static function correct_types($st){
    if ( \is_string($st) ){
      if ( self::is_buid($st) ){
        $st = bin2hex($st);
      }
      else{
        if ( self::is_json($st) ){
          if ( strpos($st, '": ') && ($json = json_decode($st)) ){
            return json_encode($json);
          }
          return $st;
        }
        $st = trim($st);
        // Not starting with a zero or ending with a zero decimal
        if ( !preg_match('/^0[^.]+|\.[0-9]*0$/', $st) ){
          if ( self::is_integer($st) && ((substr((string)$st, 0, 1) !== '0') || ($st === '0')) ){
            $tmp = (int)$st;
            if ( ($tmp < PHP_INT_MAX) && ($tmp > -PHP_INT_MAX) ){
              return $tmp;
            }
          }
          // If it is a decimal, not starting or ending with a zero
          else if ( self::is_decimal($st) ){
            return (float)$st;
          }
        }
      }
    }
    else if ( \is_array($st) ){
      foreach ( $st as $k => $v ){
        $st[$k] = self::correct_types($v);
      }
    }
    else if ( \is_object($st) ){
      $vs = get_object_vars($st);
      foreach ( $vs as $k => $v ){
        $st->$k = self::correct_types($v);
      }
    }
    return $st;
  }
public static function correct_types ( $ st ) { if ( \ is_string ( $ st ) ) { if ( self :: is_buid ( $ st ) ) { $ st = bin2hex ( $ st ) ; } else { if ( self :: is_json ( $ st ) ) { if ( strpos ( $ st , '": ' ) && ( $ json = json_decode ( $ st ) ) ) { return json_encode ( $ json ) ; } return $ st ; } $ st = trim ( $ st ) ; // Not starting with a zero or ending with a zero decimal if ( ! preg_match ( '/^0[^.]+|\.[0-9]*0$/' , $ st ) ) { if ( self :: is_integer ( $ st ) && ( ( substr ( ( string ) $ st , 0 , 1 ) !== '0' ) || ( $ st === '0' ) ) ) { $ tmp = ( int ) $ st ; if ( ( $ tmp < PHP_INT_MAX ) && ( $ tmp > - PHP_INT_MAX ) ) { return $ tmp ; } } // If it is a decimal, not starting or ending with a zero else if ( self :: is_decimal ( $ st ) ) { return ( float ) $ st ; } } } } else if ( \ is_array ( $ st ) ) { foreach ( $ st as $ k => $ v ) { $ st [ $ k ] = self :: correct_types ( $ v ) ; } } else if ( \ is_object ( $ st ) ) { $ vs = get_object_vars ( $ st ) ; foreach ( $ vs as $ k => $ v ) { $ st -> $ k = self :: correct_types ( $ v ) ; } } return $ st ; }
If it looks like an int or float type, the string variable is converted into the correct type.

```php
\bbn\x::dump(\bbn\str::correct_types(1230));
// (int) 1230
\bbn\x::dump(\bbn\str::correct_types(12.30));
// (float) 12.3
\bbn\x::dump(\bbn\str::correct_types("12.3"));
// (float) 12.3
\bbn\x::dump(\bbn\str::correct_types([1230]));
// (int) [1230]
```

@param mixed $st
@return mixed
If it looks like an int or float type the string variable is converted into the correct type .