I have a column named ip_management.id_address
in my database. I want to select all IP addresses and save them in a flat file (.txt). I tried to put them into an array first and then save it to text file.
Here's my code:
$query = "SELECT ip_address FROM ip_management";
$result = mysql_query($query);
$result_array = array();
while($row = mysql_fetch_assoc($result)) {
$result_array[] = $row;
}
print_r($result_array);
$file_handle = fopen($create_name, 'w') or die("Error: Can't open file");
foreach($result_array as $key => $value) {
fwrite($file_handle,$value."|");
}
But I get this result in my text file:
Array|Array|Array|...
I want IP addresses to appear in my text file, something like this:
10.10.10.10|11.11.11.11|12.12.12.12|...
What's wrong with my code?