PHP implements the Kuxun train timetable collection program

Source: Internet
Author: User
Cool-news trains are encoded in Json format. when collecting trains, you can directly collect trains. this interface can organize station, mileage, price, and other information into a table to facilitate processing. The standard version of the train collector can be used directly, and other program users can change the PHP code to run. & Lt ;? Phperror_reporting (7);/* vehicle count */$ id $ LabelAr

Cool-news trains are encoded in Json format. when collecting trains, you can directly collect trains. this interface can organize station, mileage, price, and other information into a table to facilitate processing.

The standard version of the train collector can be used directly, and other program users can change the PHP code to run.

 Seattypes); foreach ($ content-> stations as $ key => $ station) {$ stationid = $ key + 1; $ pricelist = ""; $ distance = $ station-> distance; $ runtime = $ station-> runtime; foreach ($ seattypes as $ type) {switch ($ type) {case 'yz ': $ price = $ station-> price-> yz; break; case 'rz': $ price = $ station-> price-> rz; break; case 'yw ': $ price = $ station-> price-> ywx; break; case 'rw ': $ price = $ station-> price-> rwx; break; case 'yz ': $ price = $ station-> price-> ydz; break; case 'edz': $ price = $ station-> price-> edz; break; default: $ price = 0;} $ pricelist. ="{$ Price} RMB\ N ";}$ me. ="       {$ Stationid}       {$ Id}       {$ Station-> name}       {$ Station-> arrivaltime}       {$ Station-> processing time}       {$ Station-> staytime}       {$ Station-> runtime}       {$ Station-> distance} km{$ Pricelist}\ N ";}/* generate seat type */function getSeattype ($ type) {$ seattypes = array (" yz "=>" hard seat ", "rz" => "soft seat", "yw" => "hard sleeper", "yws" => "hard sleeper", "ywz" => "hard sleeper ", "ywx" => "hard sleeper", "rw" => "soft sleeper", "rws" => "soft sleeper", "rwx" => "soft sleeper ", "ydz" => "first class", "edz" => "second class"); return $ seattypes [$ type];} /* generate a table */function getInfo ($ id, $ seattypes, $ body, $ distance, $ runtime) {foreach ($ seattypes as $ value) based on the seat type) {$ value = getSeattype ($ value); $ seattype. ="$ Value\ R \ n ";} return $ body ="
 {$ Seattype}
   {$ Body}
   
Vehicle count:{$ Id}(Full course: {$ distance} km)
Site Count Vehicle count Site Name Arrival time Driving time Stay Running time Mileage
Range: {$ distance} km Full course: {$ runtime}
";}$ LabelArray ['Introduction'] = getInfo ($ id, $ seattypes, $ me, $ distance, $ runtime ); // ############# the above is the user's Operation region #############//##### ####### the following statements must be retained, we recommend that you do not change the value ###### // ob_clean (); echo serialize ($ LabelArray);?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.