php-general Digest 10 Sep 2011 08:35:37 -0000 Issue 7472
php-general Digest 10 Sep 2011 08:35:37 - Issue 7472 Topics (messages 314747 through 314767): Re: array problem 314747 by: Joshua Stoutenburg 314748 by: Steve Staples 314749 by: Adam Balogh 314750 by: Ashley Sheridan Repetitive answers . . . 314751 by: Joshua Stoutenburg 314752 by: Daniel Brown 314753 by: Shawn McKenzie 314754 by: Marc Guay 314755 by: Joshua Stoutenburg 314756 by: HallMarc Websites 314757 by: Joshua Stoutenburg 314758 by: Tedd Sperling 314759 by: George Langley 314760 by: Robert Cummings 314761 by: Robert Cummings 314762 by: Daniel Brown 314763 by: Larry Martell 314764 by: Tedd Sperling 314765 by: George Langley 314766 by: Lester Caine PHP cron job optimization 314767 by: muad shibani Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- The function fgetcsv() returns an array. http://php.net/manual/en/function.fgetcsv.php On Fri, Sep 9, 2011 at 9:00 AM, Marc Fromm marc.fr...@wwu.edu wrote: I am reading a csv file into an array. The csv file. users.csv file contents: w12345678,a w23456789,b w34567890,c $csvfilename = users.csv; $handle = fopen($csvfilename, r); if($handle) { while (($line = fgetcsv($handle, 1000, ,)) !== FALSE) { $arrUsers[] = $line; } fclose($handle); } When I echo out the elements in the elements in the array $arrUsers I get: Array Array Array foreach ($arrUsers as $user){ echo $user . br /; } I can't figure out why the word Array is replacing the actual data. ---End Message--- ---BeginMessage--- On Fri, 2011-09-09 at 16:00 +, Marc Fromm wrote: I am reading a csv file into an array. The csv file. users.csv file contents: w12345678,a w23456789,b w34567890,c $csvfilename = users.csv; $handle = fopen($csvfilename, r); if($handle) { while (($line = fgetcsv($handle, 1000, ,)) !== FALSE) { $arrUsers[] = $line; } fclose($handle); } When I echo out the elements in the elements in the array $arrUsers I get: Array Array Array foreach ($arrUsers as $user){ echo $user . br /; } I can't figure out why the word Array is replacing the actual data. Try print_r($arrUsers); also, the $line is an array of the CSV, so you're storing an array, within the array $arrUsers. foreach ($arrUsers as $user){ foreach ($user as $val) { echo $val . br /; } echo 'hr /'; } -- Steve Staples Web Application Developer 519.258.2333 x8414 ---End Message--- ---BeginMessage--- hi, try to use print_r or var_dump to echo compound data type ---End Message--- ---BeginMessage--- You are echoing out an array. If you use something like print_r() or var_dump() you will see the array elements Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Marc Fromm marc.fr...@wwu.edu wrote: I am reading a csv file into an array. The csv file. users.csv file contents: w12345678,a w23456789,b w34567890,c $csvfilename = users.csv; $handle = fopen($csvfilename, r); if($handle) { while (($line = fgetcsv($handle, 1000, ,)) !== FALSE) { $arrUsers[] = $line; } fclose($handle); } When I echo out the elements in the elements in the array $arrUsers I get: Array Array Array foreach ($arrUsers as $user){ echo $user . br /; } I can't figure out why the word Array is replacing the actual data. ---End Message--- ---BeginMessage--- I'm new to this email list . . . But is it customary to answer a question after it's already been adequately answered? Not trying to step on any toes. I just think if I were asking the question, it would be unpleasant to continue receiving answers, especially the same answer, after receiving one that is prompt, accurate, precise, concise, and adequate. Likewise, if I had answered the question -- promptly, accurately, precisely, concisely, adequately -- I would find it equally, if not more, unpleasant to see my answer displaced, or
php-general Digest 11 Sep 2011 00:16:35 -0000 Issue 7473
php-general Digest 11 Sep 2011 00:16:35 - Issue 7473 Topics (messages 314768 through 314771): Re: PHP cron job optimization 314768 by: Sean Greenslade 314769 by: Gary Golden 314770 by: MUAD SHIBANI 314771 by: Eric Butera Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Sat, Sep 10, 2011 at 4:35 AM, muad shibani muad.shib...@gmail.comwrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Do them one at a time. Fetching web pages isn't a particularly taxing job for any decent server. My advice is just to try it. Even if you solution isn't 'elegant' or 'clever,' if it works and doesn't bog down the server, that's a win in my book. -- --Zootboy Sent from my PC. ---End Message--- ---BeginMessage--- I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Just watch your memory and you'll be fine. As was stated fetching an rss feed is fast and cheap, so I would contrariwise think about paralleling if I would you. signature.asc Description: OpenPGP digital signature ---End Message--- ---BeginMessage--- thanks a lot after I test it I will share the code .. Thanks again On Sat, Sep 10, 2011 at 11:20 AM, Gary Golden m...@garygolden.me wrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Just watch your memory and you'll be fine. As was stated fetching an rss feed is fast and cheap, so I would contrariwise think about paralleling if I would you. -- * ___ Muad Shibani* * * Aden Yemen Mobile: 00967 733045678 Mobile: 00967 711811232 www.muadshibani.com ---End Message--- ---BeginMessage--- On Sat, Sep 10, 2011 at 1:47 PM, Sean Greenslade zootboys...@gmail.com wrote: On Sat, Sep 10, 2011 at 4:35 AM, muad shibani muad.shib...@gmail.comwrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Do them one at a time. Fetching web pages isn't a particularly taxing job for any decent server. My advice is just to try it. Even if you solution isn't 'elegant' or 'clever,' if it works and doesn't bog down the server, that's a win in my book. -- --Zootboy Sent from my PC. Traversing the internet is one of the most expensive IO operations that can be performed. The OP should try and split the work into several processes and utilize async connections via a mechanism like curl_multi [1]. Doing 1,000 connections one at a time is abysmal if you're blocked for even 3 seconds per connection. I'd work by making a two step process that has one cron job for constantly fetching/updating feeds into a store then another process that constantly checks for updates inside aforementioned store. [1] http://us3.php.net/manual/en/function.curl-multi-add-handle.php ---End Message---
[PHP] PHP cron job optimization
I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance
Re: [PHP] PHP cron job optimization
On Sat, Sep 10, 2011 at 4:35 AM, muad shibani muad.shib...@gmail.comwrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Do them one at a time. Fetching web pages isn't a particularly taxing job for any decent server. My advice is just to try it. Even if you solution isn't 'elegant' or 'clever,' if it works and doesn't bog down the server, that's a win in my book. -- --Zootboy Sent from my PC.
Re: [PHP] PHP cron job optimization
I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Just watch your memory and you'll be fine. As was stated fetching an rss feed is fast and cheap, so I would contrariwise think about paralleling if I would you. signature.asc Description: OpenPGP digital signature
Re: [PHP] PHP cron job optimization
thanks a lot after I test it I will share the code .. Thanks again On Sat, Sep 10, 2011 at 11:20 AM, Gary Golden m...@garygolden.me wrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Just watch your memory and you'll be fine. As was stated fetching an rss feed is fast and cheap, so I would contrariwise think about paralleling if I would you. -- * ___ Muad Shibani* * * Aden Yemen Mobile: 00967 733045678 Mobile: 00967 711811232 www.muadshibani.com
Re: [PHP] PHP cron job optimization
On Sat, Sep 10, 2011 at 1:47 PM, Sean Greenslade zootboys...@gmail.com wrote: On Sat, Sep 10, 2011 at 4:35 AM, muad shibani muad.shib...@gmail.comwrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas Thank you in advance Do them one at a time. Fetching web pages isn't a particularly taxing job for any decent server. My advice is just to try it. Even if you solution isn't 'elegant' or 'clever,' if it works and doesn't bog down the server, that's a win in my book. -- --Zootboy Sent from my PC. Traversing the internet is one of the most expensive IO operations that can be performed. The OP should try and split the work into several processes and utilize async connections via a mechanism like curl_multi [1]. Doing 1,000 connections one at a time is abysmal if you're blocked for even 3 seconds per connection. I'd work by making a two step process that has one cron job for constantly fetching/updating feeds into a store then another process that constantly checks for updates inside aforementioned store. [1] http://us3.php.net/manual/en/function.curl-multi-add-handle.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP cron job optimization
On 10 Sep 2011, at 09:35, muad shibani wrote: I want to design an application that reads news from RSS sources. I have about 1000 RSS feed to collect from. I also will use Cron jobs every 15 minutes to collect the data. the question is: Is there a clever way to collect all those feed items without exhausting the server any Ideas I designed a job queuing system a while back when I had a similar problem. You can read about it here: http://stut.net/2009/05/29/php-job-queue/. Set that type of system up and add a job for each feed, set to run every 15 minutes. You can then watch the server and tune the number of concurrent job processors so you get the optimum balance between load and speed. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php