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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.