php - Create another dimension to an array housing urls with base url -
Currently I have an array that lists the email address as values in the form of the key and the URL, I create parse_url (unless some better suggestion) and another dimension in the array with the base URL. I currently have this:
array ('email@email.com' = & gt; array (0 = & gt; 'http://www.google.co.uk/ Foo / bar ', 1 = & gt;' http://www.reddit.com/r/programming/ ',),' email2@email.com '= & gt; array (0 = & gt;' http: //stackoverflow.com/faq ', 1 = & gt;' http://de.php.net/parse_url '),' email3@email.com '=> Array (0 = & gt;' http: //www.bleepingcomputer.com/forum/ ',),)
and that I should have this output:
array (' email @ Email.com '= & gt; array (0 = & gt;' http://www.google.co.uk/foo/bar ', array (0 = & gt;' www.google.co.uk ' ) 1 = & gt; 'http: /www.reddit.com/r/programming/', array (0 = & gt; 'www.reddit.com'),), 'email2@email.com' = & Array (0 = & gt; 'http: /stackoverflow.com/faq', array (0 = & gt; 'http://stackoverflow.com') 1 = & Gt; 'http://de.php.net/parse_url', array (0 = & gt; 'd.php.net'),), 'Email3@email.com' => Array (0 = & Gt; 'http://www.bleepingcomputer.com/forums/', array (0 = & gt; 'http://www.bleepingcomputer.com'),),)
< P> Any help is greatly appreciated!
I believe this should do the trick:
{$ Some_array [$ email] [$ key] = array ($ url, parse_url ($ url, $ urlist $ key = & gt; $ url) {foreach ($ some_array as $ email = & gt; $ urlist) PHP_URL_HOST)); }}
Comments
Post a Comment