Php coding help

Discussion in 'PHP' started by webcosmo, Jun 19, 2007.

  1. #1
    I am basically a asp guy. Trying convert this little piece of php code below to asp.net. What it does is read the content from a page. I dont understand the last line in red color, what it does. Can somebody please explain.

    $request = 'http://www.google.com';
    $output = unserialize(file_get_contents($request));
    $incoming_links=$output[ResultSet][totalResultsAvailable];
     
    webcosmo, Jun 19, 2007 IP
  2. Cesay

    Cesay Peon

    Messages:
    121
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The square brackets mean it's an array. Since you have 2 sets, it's a 2-dimensional array so the value for $incoming_links is being set to whatever the equivalent is in the output array in the position of the 2 values ResultSet and totalResultsAvailable.
     
    Cesay, Jun 19, 2007 IP
  3. e39m5

    e39m5 Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Is that the complete code? Try echoing $incoming_links to see what it holds.

    e39m5
     
    e39m5, Jun 19, 2007 IP
  4. picobello

    picobello Well-Known Member

    Messages:
    572
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    110
    #4
    I guess you replaced the real URL by the Google one for the sake of the POST because that kind of processing does not make any sense for Google home page !
     
    picobello, Jun 19, 2007 IP
  5. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you should use:
    $output['ResultSet']['totalResultsAvailable'];
    PHP:
    though, as php will throw a NOTICE error when parsing your code (if error_reporting is set to E_ALL). It will either display the error, or store it in the error.log file of you server. The reason why it will throw this error is because php will look for a constant named ResultSet and totalResultsAvailable, and won't be able to find it

    Anyway: Cesay allready gave the solution to your problem :)
     
    UnrealEd, Jun 19, 2007 IP
  6. webcosmo

    webcosmo Notable Member

    Messages:
    5,840
    Likes Received:
    153
    Best Answers:
    2
    Trophy Points:
    255
    #6
    yes i replaced the url with google, i just put an example there.
    The value hold by the variable $output is as follows:

    a:1:{s:9:"ResultSet";a:4:{s:21:"totalResultsAvailable";s:3:"555";s:19:"firstResultPosition";s:1:"1";s:20:"totalResultsReturned";s:2:"50";s:6:"Result";a:50:{i:0;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:32:"http://aldebaran14.blogspot.com/";s:8:"ClickUrl";s:32:"http://aldebaran14.blogspot.com/";}i:1;a:3:{s:5:"Title";s:15:"NepalChurch.com";s:3:"Url";s:50:"http://www.nepalchurch.com/general/usefullinks.php";s:8:"ClickUrl";s:50:"http://www.nepalchurch.com/general/usefullinks.php";}i:2;a:3:{s:5:"Title";s:17:"ADVERTISE ME FREE";s:3:"Url";s:31:"http://www.advertisemefree.com/";s:8:"ClickUrl";s:31:"http://www.advertisemefree.com/";}i:3;a:3:{s:5:"Title";s:41:"Stories Tagged 'free tool' " Netscape.com";s:3:"Url";s:37:"http://www.netscape.com/tag/free+tool";s:8:"ClickUrl";s:37:"http://www.netscape.com/tag/free+tool";}i:4;a:3:{s:5:"Title";s:36:"LINK EXCHANGE BY WWW.SILOMSTREET.COM";s:3:"Url";s:40:"http://www.silomstreet.com/link-exchange";s:8:"ClickUrl";s:40:"http://www.silomstreet.com/link-exchange";}i:5;a:3:{s:5:"Title";s:10:"Misc Links";s:3:"Url";s:40:"http://blankmediaoutlet.com/page/1041120";s:8:"ClickUrl";s:40:"http://blankmediaoutlet.com/page/1041120";}i:6;a:3:{s:5:"Title";s:84:"Travel Argentina Chile, cruises, honeymoons, accessible wheelchair, tailormade tours";s:3:"Url";s:47:"http://travel-chile-argentina.korke.com/ukl.htm";s:8:"ClickUrl";s:47:"http://travel-chile-argentina.korke.com/ukl.htm";}i:7;a:3:{s:5:"Title";s:21:"Rachmistrz Prace Blog";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/pl/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/pl/";}i:8;a:3:{s:5:"Title";s:21:"Ra?unar Poslovi Blog";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/sr/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/sr/";}i:9;a:3:{s:5:"Title";s:22:"Ra?unalo Poslovi Blog";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/hr/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/hr/";}i:10;a:3:{s:5:"Title";s:38:"PHP MySQL: trying to retrive birthdays";s:3:"Url";s:36:"http://www.ozzu.com/ftopic75979.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic75979.html";}i:11;a:3:{s:5:"Title";s:43:"??????????s ???????? Blog";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/el/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/el/";}i:12;a:3:{s:5:"Title";s:17:"BUSINESS-TRAVEL 5";s:3:"Url";s:49:"http://vjegifts.com/index.cfm/BUSINESS-TRAVEL%205";s:8:"ClickUrl";s:49:"http://vjegifts.com/index.cfm/BUSINESS-TRAVEL%205";}i:13;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:47:"http://www.nutang.com/bliss/weblog/p_9/KkaMA67/";s:8:"ClickUrl";s:47:"http://www.nutang.com/bliss/weblog/p_9/KkaMA67/";}i:14;a:3:{s:5:"Title";s:39:"???????? ?????? Jobs Blog";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/bg/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/bg/";}i:15;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:26:"http://kkama67.nutang.com/";s:8:"ClickUrl";s:26:"http://kkama67.nutang.com/";}i:16;a:3:{s:5:"Title";s:32:"Crazy Quilt: Holi and Springtime";s:3:"Url";s:64:"http://aldebaran14.blogspot.com/2007/03/holi-and-springtime.html";s:8:"ClickUrl";s:64:"http://aldebaran14.blogspot.com/2007/03/holi-and-springtime.html";}i:17;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:45:"http://www.pkblogs.com/aldebaran14/index.html";s:8:"ClickUrl";s:45:"http://www.pkblogs.com/aldebaran14/index.html";}i:18;a:3:{s:5:"Title";s:15:"Problem of form";s:3:"Url";s:36:"http://www.ozzu.com/ftopic76036.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic76036.html";}i:19;a:3:{s:5:"Title";s:52:"Blazoom Malaysia - FREE Classified Ads :: Ad Details";s:3:"Url";s:55:"http://www.blazoom.com/detail.php?siteid=3309&contact=1";s:8:"ClickUrl";s:55:"http://www.blazoom.com/detail.php?siteid=3309&contact=1";}i:20;a:3:{s:5:"Title";s:33:"SITE REVIEW: Local Classified Ads";s:3:"Url";s:36:"http://www.ozzu.com/ftopic75485.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic75485.html";}i:21;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:50:"http://aldebaran14.blogspot.com/search/label/Bible";s:8:"ClickUrl";s:50:"http://aldebaran14.blogspot.com/search/label/Bible";}i:22;a:3:{s:5:"Title";s:16:"SITE REVIEW: GLA";s:3:"Url";s:36:"http://www.ozzu.com/ftopic75484.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic75484.html";}i:23;a:3:{s:5:"Title";s:23:"Crazy Quilt: March 2007";s:3:"Url";s:55:"http://aldebaran14.blogspot.com/2007_03_01_archive.html";s:8:"ClickUrl";s:55:"http://aldebaran14.blogspot.com/2007_03_01_archive.html";}i:24;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:40:"http://kkama67.nutang.com/comment_64211/";s:8:"ClickUrl";s:40:"http://kkama67.nutang.com/comment_64211/";}i:25;a:3:{s:5:"Title";s:53:"Any Body can help me To search from data base in .net";s:3:"Url";s:36:"http://www.ozzu.com/ftopic76030.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic76030.html";}i:26;a:3:{s:5:"Title";s:23:"enumerate api functions";s:3:"Url";s:36:"http://www.ozzu.com/ftopic76019.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic76019.html";}i:27;a:3:{s:5:"Title";s:31:"Crazy Quilt: First Blogversary!";s:3:"Url";s:62:"http://aldebaran14.blogspot.com/2007/03/first-blogversary.html";s:8:"ClickUrl";s:62:"http://aldebaran14.blogspot.com/2007/03/first-blogversary.html";}i:28;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:48:"http://www.nutang.com/bliss/weblog/p_17/KkaMA67/";s:8:"ClickUrl";s:48:"http://www.nutang.com/bliss/weblog/p_17/KkaMA67/";}i:29;a:3:{s:5:"Title";s:43:"Javascript selectedIndex problem in Firefox";s:3:"Url";s:36:"http://www.ozzu.com/ftopic76012.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic76012.html";}i:30;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:34:"http://www.inblogs.net/aldebaran14";s:8:"ClickUrl";s:34:"http://www.inblogs.net/aldebaran14";}i:31;a:3:{s:5:"Title";s:57:"AdBrite - Advertise on Web Cosmo : Free Local Classifieds";s:3:"Url";s:72:"http://www.adbrite.com/mb/commerce/purchase_form.php?opid=274336&afsid=1";s:8:"ClickUrl";s:72:"http://www.adbrite.com/mb/commerce/purchase_form.php?opid=274336&afsid=1";}i:32;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:53:"http://aldebaran14.blogspot.com/search/label/Marriage";s:8:"ClickUrl";s:53:"http://aldebaran14.blogspot.com/search/label/Marriage";}i:33;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:48:"http://www.nutang.com/bliss/weblog/p_23/KkaMA67/";s:8:"ClickUrl";s:48:"http://www.nutang.com/bliss/weblog/p_23/KkaMA67/";}i:34;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:48:"http://www.nutang.com/bliss/weblog/p_21/KkaMA67/";s:8:"ClickUrl";s:48:"http://www.nutang.com/bliss/weblog/p_21/KkaMA67/";}i:35;a:3:{s:5:"Title";s:24:"SITE REVIEW: irt2000.com";s:3:"Url";s:36:"http://www.ozzu.com/ftopic74624.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic74624.html";}i:36;a:3:{s:5:"Title";s:119:"Search Engine Optimization,Search Engine Optimization Services,SEO Company,Outsourcing SEO Services,SEO India,Link ... ";s:3:"Url";s:24:"http://www.seodense.com/";s:8:"ClickUrl";s:24:"http://www.seodense.com/";}i:37;a:3:{s:5:"Title";s:27:"Web Marketing Expert Wanted";s:3:"Url";s:51:"http://boston.craigslist.org/gbs/cpg/348283467.html";s:8:"ClickUrl";s:51:"http://boston.craigslist.org/gbs/cpg/348283467.html";}i:38;a:3:{s:5:"Title";s:31:"Trabajos Blog de la computadora";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/es/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/es/";}i:39;a:3:{s:5:"Title";s:34:"Premier Villas Property Management";s:3:"Url";s:59:"http://www.premiervillasmanagement.com/links2/Internet.html";s:8:"ClickUrl";s:59:"http://www.premiervillasmanagement.com/links2/Internet.html";}i:40;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:47:"http://www.nutang.com/bliss/weblog/p_5/KkaMA67/";s:8:"ClickUrl";s:47:"http://www.nutang.com/bliss/weblog/p_5/KkaMA67/";}i:41;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:48:"http://www.nutang.com/bliss/weblog/p_12/KkaMA67/";s:8:"ClickUrl";s:48:"http://www.nutang.com/bliss/weblog/p_12/KkaMA67/";}i:42;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:50:"http://aldebaran14.blogspot.com/search/label/books";s:8:"ClickUrl";s:50:"http://aldebaran14.blogspot.com/search/label/books";}i:43;a:3:{s:5:"Title";s:20:"FileForum | WebCosmo";s:3:"Url";s:58:"http://fileforum.betanews.com/detail/WebCosmo/1004997137/1";s:8:"ClickUrl";s:58:"http://fileforum.betanews.com/detail/WebCosmo/1004997137/1";}i:44;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:47:"http://www.nutang.com/bliss/weblog/p_8/KkaMA67/";s:8:"ClickUrl";s:47:"http://www.nutang.com/bliss/weblog/p_8/KkaMA67/";}i:45;a:3:{s:5:"Title";s:16:"Marvelous Things";s:3:"Url";s:40:"http://kkama67.nutang.com/comment_60918/";s:8:"ClickUrl";s:40:"http://kkama67.nutang.com/comment_60918/";}i:46;a:3:{s:5:"Title";s:21:"Computer Arbeide Blog";s:3:"Url";s:41:"http://hotjobs.taragana.com/index.php/no/";s:8:"ClickUrl";s:41:"http://hotjobs.taragana.com/index.php/no/";}i:47;a:3:{s:5:"Title";s:11:"Crazy Quilt";s:3:"Url";s:53:"http://aldebaran14.blogspot.com/search/label/blogroll";s:8:"ClickUrl";s:53:"http://aldebaran14.blogspot.com/search/label/blogroll";}i:48;a:3:{s:5:"Title";s:53:"Link Directory - Business - Page 221 :: Gowealthy.com";s:3:"Url";s:72:"http://www.gowealthy.com/site/links/category/business/page_221/index.asp";s:8:"ClickUrl";s:72:"http://www.gowealthy.com/site/links/category/business/page_221/index.asp";}i:49;a:3:{s:5:"Title";s:24:"SITE REVIEW: Blue Rincon";s:3:"Url";s:36:"http://www.ozzu.com/ftopic75421.html";s:8:"ClickUrl";s:36:"http://www.ozzu.com/ftopic75421.html";}}}}
     
    webcosmo, Jun 19, 2007 IP
  7. picobello

    picobello Well-Known Member

    Messages:
    572
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    110
    #7
    serialize is a wonderful php method to convert an array of any kind to a string representation. To reverse the operation, there is unserialize starting from the string. Very useful to persist any kind of structured information in a text-oriented storage.
     
    picobello, Jun 19, 2007 IP