You are here: Re: Processing Arrays « All PHP « IT news, forums, messages
Re: Processing Arrays

Posted by Rik on 07/20/06 03:00

Samuλl van Laere wrote:
> Currently I use a script that needs a lot of work to maintain,
> I call it like this:
> http://www.somedomain.nl/process.php?url=http://www.somedomain.nl/page/1/
> and would need to replace the url by hand to process another page.

Hmmz, that should be somethig different, look up urlenode()/rawurldecode().

> I'm just wondering how to automate this process.
> So i've written a full list of a url's that need to be processed
> and have written it to a file:
> links.txt
>
> Next I put the contents of this file into an array ($lines):
>
> $filename="links.txt";
> $lines = array();
> $file = fopen($filename, "r");
> while(!feof($file)) {
>
> //read file line by line into a new array element
> $lines[] = fgets($file, 4096);
>
> }
> fclose ($file);

It works, but hardly elegant.

> But how can I walk each item in the array with GET (or POST)?
> Basicly the script would need to process the first item, before
> starting with the next in line.

$target = false;
foreach($lines as $target){
if(in_array($_GET['url'],$lines) $target= $_GET['url'];
if($target!==false) break;
}

if(!$target){
$target = reset($lines);
}

Grtz,
--
Rik Wasmus

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация