w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
PHP ip2long only picking up last entry if input from a text file

You must remove the newlines from the string using something like trim

<?php
$text_file = 'ip.txt';
//begin reading text file
if (($file = fopen($text_file, "r")) !== FALSE) {
    echo "Begin IP Convertion 
";
    while ($line = fgets($file)) {
        echo trim($line) . " = " . ip2long(trim($line)) . "
";
    }
} else {echo "No file found 
";}

fclose($file);
?>




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.