3v4l.org

run code in 300+ PHP versions simultaneously
<?php function expandShortUrl($shortUrl) { $context = stream_context_create(array( "http" => array( "method" => "HEAD", "follow_location" => 1, "ignore_errors" => 1 ) )); $headers = get_headers($shortUrl, 1, $context); if (isset($headers["Location"])) { return $headers["Location"]; } else { return $shortUrl; } } function expandShortUrls($shortUrls) { $expandedUrls = array(); foreach ($shortUrls as $shortUrl) { $expandedUrl = expandShortUrl($shortUrl); $expandedUrls[] = $expandedUrl; } return $expandedUrls; } // Kısa linkler $shortUrls = array( "https://www.etsy.com/listing/664135699", "https://www.etsy.com/listing/612721265", "https://www.etsy.com/listing/596197569", "https://www.etsy.com/listing/576635976", "https://www.etsy.com/listing/466790858", "https://www.etsy.com/listing/249127718", "https://www.etsy.com/listing/232208668", "https://www.etsy.com/listing/1741336387", "https://www.etsy.com/listing/1680069076", "https://www.etsy.com/listing/1659620413" ); // Kısa linkleri genişlet $expandedUrls = expandShortUrls($shortUrls); // Genişletilmiş linkleri yazdır foreach ($expandedUrls as $index => $expandedUrl) { echo ($index + 1) . ". " . $expandedUrl . "\n"; }

preferences:
26.54 ms | 405 KiB | 5 Q