src/bbn/str.php
public static function parse_url($url): array
  {
    $url = self::cast($url);
    $r = x::merge_arrays(parse_url($url), ['url' => $url,'query' => '','params' => []]);
    if ( strpos($url,'?') > 0 )
    {
      $p = explode('?',$url);
      $r['url'] = $p[0];
      $r['query'] = $p[1];
      $ps = explode('&',$r['query']);
      foreach ( $ps as $p ){
        $px = explode('=',$p);
        $r['params'][$px[0]] = $px[1];
      }
    }
    return $r;
  }
public static function parse_url($url): array
  {
    $url = self::cast($url);
    $r = x::merge_arrays(parse_url($url), ['url' => $url,'query' => '','params' => []]);
    if ( strpos($url,'?') > 0 )
    {
      $p = explode('?',$url);
      $r['url'] = $p[0];
      $r['query'] = $p[1];
      $ps = explode('&',$r['query']);
      foreach ( $ps as $p ){
        $px = explode('=',$p);
        $r['params'][$px[0]] = $px[1];
      }
    }
    return $r;
  }
public static function parse_url ( $ url ) : array { $ url = self :: cast ( $ url ) ; $ r = x :: merge_arrays ( parse_url ( $ url ) , [ 'url' => $ url , 'query' => '' , 'params' => [ ] ] ) ; if ( strpos ( $ url , '?' ) > 0 ) { $ p = explode ( '?' , $ url ) ; $ r [ 'url' ] = $ p [ 0 ] ; $ r [ 'query' ] = $ p [ 1 ] ; $ ps = explode ( '&' , $ r [ 'query' ] ) ; foreach ( $ ps as $ p ) { $ px = explode ( '=' , $ p ) ; $ r [ 'params' ] [ $ px [ 0 ] ] = $ px [ 1 ] ; } } return $ r ; }
Returns an array containing any of the various components of the URL that are present.

```php
\bbn\x::hdump(\bbn\str::parse_url('http://localhost/phpmyadmin/?db=test&table=users&server=1&target=&token=e45a102c5672b2b4fe84ae75d9148981');
/* (array)
[
'scheme' => 'http',
'host' => 'localhost',
'path' => '/phpmyadmin/',
'query' => 'db=test&table=users&server=1&target=&token=e45a102c5672b2b4fe84ae75d9148981',
'url' => 'http://localhost/phpmyadmin/',
'params' => [
'db' => 'test',
'table' => 'users',
'server' => '1',
'target' => '',
'token' => 'e45a102c5672b2b4fe84ae75d9148981',
],
]
```

@param string $url The url.
@return array
Returns an array containing any of the various components of the URL that are present .