Jump to content

Generating vars?


aximbigfan

Recommended Posts

I have a little issue here.

 

I want to make a system where RSS URLs may be entered into a text box, then saved to a .ini file (parse_ini_file ()).

 

then I want on a seperate page to be a drop down box, with the different URLs.

 

I knwo how to do the majority of this, liek how to save the URLs,

 

but lets say I save each url in the ini file as

URL[1] = ""

URL[2] = ""

 

ect.

 

How do I get PHP to figure out that it needs to loop and get the contents of each saved URL, then output them on a drop down box?

 

Thanks,

chris

Link to comment
https://forums.phpfreaks.com/topic/96065-generating-vars/
Share on other sites

If your file already looks like...

 

URL[1] = "http://google.com/"
URL[2] = "http://yahoo.com/"

 

Then you can try....

<?php

  $url = explode("\n",file_get_contents($file));

    foreach($url as $u) 
    {
       preg_match('/URL\[[0-9]+\] \= \"([aZ-zZ0-9\_\:\/\.\~]+)\"/i', $u, $links[$i]);
       $urls[] = $links[$i][1];
       $i++;
    }

/* The $urls array will output the following...

Array
(
    [0] => http://google.com/
    [1] => http://yahoo.com/
)

*/

?>

Link to comment
https://forums.phpfreaks.com/topic/96065-generating-vars/#findComment-491835
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.