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
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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.