| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Sep 2003
Posts: 889
![]() ![]() | PHP preg expressions... I have this file full of text. It was actually a select drop down field. I want to insert everything into the database so I need to seperate everything in it even the optgroups. Ive tried everything I can think of... Here is the file:Link Here is an exampe of how I want it to be displayed (its the first one): Code: "Automobiles / Vehicles" 4X4/SUVs Acura Aston Martin Audio / Video BMW Bugatti Buick Cadillac Chevrolet Chrysler Citroen Classic Cobra Convertibles Electronics Exotic Ferrari Ford Formula 1 Hummer Hydrogen Powered Insurance Jeeps Land Rover Land Rovers Leased Lexus Mazda Mercedes-Benz Motorcycles Muscle Cars NASCAR New Nissan Peugeot Pickup Trucks Pontiac Porsche Private Pilot Racing Recreational Vehicles (RVs) Renault Repair Rolls Royce Shopping Sports Bikes Taxi Technology/Engineering Toyota Used Volkswagen Z cars
__________________ Online Time Tracking :) |
| |
| | THREAD STARTER #3 (permalink) |
| NamePros Regular Join Date: Sep 2003
Posts: 889
![]() ![]() | ...Yea right... Would take at least twice as long...
__________________ Online Time Tracking :) |
| |
| | #4 (permalink) |
| NamePros Member Join Date: Jul 2003 Location: Canterbury, UK
Posts: 99
![]() | Hi, just use 2 "preg_match_all" function calls and a bit of php inbetween them to build up an array of optiongroups / options: PHP Code: $optgroups will be an array like this: array ( "Option Group 1" => array("Option 1", "Option2", etc), "Option Group 2" => array("Option 1", "Option2", etc), etc, etc So you can just step through the array and insert data into mysql with mysql_query()s... hope that helps, Sam |
| |
| | THREAD STARTER #5 (permalink) |
| NamePros Regular Join Date: Sep 2003
Posts: 889
![]() ![]() | Thanks I haven't tested it but that preg expressions looks like what I needed... Thanks...
__________________ Online Time Tracking :) |
| |