manalnor Posted October 2, 2012 Share Posted October 2, 2012 Hello dear friends, If i've the following array results then how i can show it up ! array code $urlByHost = array(); foreach (explode("\n", $_POST['url']) as $value) { $parse = parse_url($value); $urlByHost[$parse['host']][] = array( 'url' => $value, 'parse' => $parse, 'md5' => md5($value), ); } asort($urlByHost); print_r($urlByHost); results Array ( [www.bing.com] => Array ( [0] => Array ( [url] => http://www.bing.com/kee [parse] => Array ( [scheme] => http [host] => www.bing.com [path] => /kee_ ) [md5] => e69d3a5bb987448e30ec8559c3634caf ) ) i want to show the host and md5 as www.bing.com e69d3a5bb987448e30ec8559c3634caf how can i call the results and show it ! ~ thanks Quote Link to comment https://forums.phpfreaks.com/topic/268990-how-to-show-the-results-of-an-array/ Share on other sites More sharing options...
jazzman1 Posted October 2, 2012 Share Posted October 2, 2012 (edited) Try, $host = ['www.bing.com'][0]['parse']['host']; $md5 = ['www.bing.com'][0]['md5']; Edited October 2, 2012 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/268990-how-to-show-the-results-of-an-array/#findComment-1382220 Share on other sites More sharing options...
jazzman1 Posted October 2, 2012 Share Posted October 2, 2012 (edited) Example, $arrInfo = array( 'www.bind.com' => array( 0 =>array( 'url' => 'http://www.bing.com/kee', 'parse' => array( 'schame' => 'http', 'host' => 'www.bing.com', 'path' => '/kee_' ), 'md5' => 'e69d3a5bb987448e30ec8559c3634caf' ) ) ); echo $arrInfo['www.bind.com'][0]['parse']['host'].'<br />'; // www.bing.com echo $arrInfo['www.bind.com'][0]['md5']; // e69d3a5bb987448e30ec8559c3634caf Edited October 2, 2012 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/268990-how-to-show-the-results-of-an-array/#findComment-1382228 Share on other sites More sharing options...
JLT Posted October 2, 2012 Share Posted October 2, 2012 (edited) The above example won't work if your array is dynamically generated, which by looking at your previous code, it is. Luckily, not all of the array is dynamic which makes this process a little easier, try the following: $urlByHost = array ( ); foreach ( explode ( "\n", $_POST [ 'url' ] ) as $value ) { $parse = parse_url ( $value ); $urlByHost [ $parse [ 'host' ] ] [ ] = array ( 'url' => $value, 'parse' => $parse, 'md5' => md5 ($value ), ); } asort ( $urlByHost ); foreach ( $urlByHost as $key => $value ) { foreach ( $value as $v ) { echo $v [ 'parse' ] [ 'host' ] . '<br />' . $v [ 'md5' ]; } } Edited October 2, 2012 by JLT Quote Link to comment https://forums.phpfreaks.com/topic/268990-how-to-show-the-results-of-an-array/#findComment-1382236 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.