Jump to content

Stripping out block of text in file


c_pattle

Recommended Posts

I have a .sql file that has the following in it

 

DROP TABLE IF EXISTS `flights`;
/*!40101 SET @saved_cs_client	 = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `flights` (
 `flight_id` int(11) NOT NULL AUTO_INCREMENT,
 `flight_icon` int(11) NOT NULL,
 `flight_path` int(11) NOT NULL,
 `flight_from` int(11) NOT NULL,
 `flight_to` int(11) NOT NULL,
 PRIMARY KEY (`flight_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

 

I have read the contents of the file using file_get_contents. I was wondering what is the best way to strip out everything before "CREATE TABLE" and everything after "CHARSET=latin1"? Does anyone have any suggestions on the best way to do it?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/273677-stripping-out-block-of-text-in-file/
Share on other sites

DROP TABLE IF EXISTS `flights`;
CREATE TABLE `flights` (
 `flight_id` int(11) NOT NULL AUTO_INCREMENT,
 `flight_icon` int(11) NOT NULL,
 `flight_path` int(11) NOT NULL,
 `flight_from` int(11) NOT NULL,
 `flight_to` int(11) NOT NULL,
 PRIMARY KEY (`flight_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.