Strings, regexp and files
        Posted  
        
            by 
                A Moose
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by A Moose
        
        
        
        Published on 2012-10-04T08:20:15Z
        Indexed on 
            2012/10/04
            9:37 UTC
        
        
        Read the original article
        Hit count: 235
        
<?php 
    $iprange = array( 
        "^12\.34\.", 
        "^12\.35\.", 
        ); 
    foreach($iprange as $var) { 
        if (preg_match($var, $_SERVER['REMOTE_ADDR'])) {
I'm looking to have a list that will constitute each of the values inside the array. Let's call it iprange.txt, from which I would extract the variable $iprange. I would also be updating the file with new ranges, but I also want to convert those strings to regexp if that's something that's needed in php, as it is in the above example. 
If you could help me with the two following issues:
- I understand that somehow I would be using an array include, but I'm not sure how to implement it. 
- I would like to run a cron that would update the text file and turn it into a regexp acceptable for use in the above example, if you think regexp is a good idea and there isn't another option. I know how to apply a cron in a directadmin gui, but I don't know what the cronned file would look like. 
© Stack Overflow or respective owner