Skip to content

Instantly share code, notes, and snippets.

@nyamsprod
Created August 22, 2022 09:28
Show Gist options
  • Save nyamsprod/a2197ba2537849b637947ccdae7449c0 to your computer and use it in GitHub Desktop.
Save nyamsprod/a2197ba2537849b637947ccdae7449c0 to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
use League\Uri\UriTemplate;
use League\Uri\Components\Query;
require 'vendor/autoload.php';
$template = 'https://api.twitter.com/{version}/{?q*}';
$params = ['q' => ['a', 'b']];
$uriTemplate = new UriTemplate($template, ['version' => '1.1']);
$uri = $uriTemplate->expand($params);
$query = Query::createFromUri($uri);
var_dump((string) $uri, $query->getAll('q'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment