Break up/parse a URL into its constituent parts in php
What is the best way to parse a URL into its corresponding paths, such that https://www.example.com/path/to/directory/file.jpeg?param1=foo¶m2=bar Results in an array holding Array( ["scheme"] => "https", ["host"] => www.example.com ["directory"] => "path/to/directory" ["filename"] => "file" ["extension] => "jpeg" ["path"] => "path/to/directory/file.jpeg", ["file"] => "file.jpeg" ["params"] => Array( ["param1"] => "foo", ["param2"] => "bar" ) ) Note: The keys do not need to be named like this, they are just an example. I have looked into parse_url, but it doesn't split up the path fine