Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Why the print_r don't output any data?

 $host = array();
 while($row = mysqli_fetch_array($result))
  {
  $host = parse_url($row['url'], PHP_URL_HOST); 
  //echo $host;
  echo "<br>";
  }

print_r($host);

What is the correct way to do this. Thanks in advance.

share|improve this question
2  
$host[] = parse_url($row['url'], PHP_URL_HOST); – MaveRick Aug 22 at 3:20

1 Answer

up vote 1 down vote accepted

Change this:

$host = parse_url($row['url'], PHP_URL_HOST);

For this:

$host[] = parse_url($row['url'], PHP_URL_HOST);

http://php.net/manual/en/language.types.array.php

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.