itsjareds Posted June 18, 2008 Share Posted June 18, 2008 How do you set a variable to what is in a php file? I have a list of numbers that will be put into an array. One file, which has the list of numbers, will be changed often. numbers.php 123.4.567.890, 098.7.654.321 myscript.php <?php $ips = <?php include("numbers.php") ?>; $banned = Array(); $banned[] = $ips; if (in_array($_SERVER['REMOTE_ADDR'], $banned)) { exit("<center><h2>You are banned from this board.</h2></center>"); } ?> Link to comment https://forums.phpfreaks.com/topic/110775-using-include-with-variables/ Share on other sites More sharing options...
Jabop Posted June 18, 2008 Share Posted June 18, 2008 Read the file contents, explode the contents by comma. Link to comment https://forums.phpfreaks.com/topic/110775-using-include-with-variables/#findComment-568314 Share on other sites More sharing options...
wildteen88 Posted June 18, 2008 Share Posted June 18, 2008 include doesn't return a value. You should use fopen/fread or file_get_contents to store the contants of a file into a variable Link to comment https://forums.phpfreaks.com/topic/110775-using-include-with-variables/#findComment-568341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.