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>"); } ?> Quote 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. Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/110775-using-include-with-variables/#findComment-568341 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.