ameliabob Posted April 24, 2012 Share Posted April 24, 2012 I am trying to do an 'explode' on a tab delimited file. when I use the line $a = explode( ,$s) where $ is the line that is tab-delimited the pound sign comments out the rest of the line. What is the correct syntax to do this? Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted April 24, 2012 Share Posted April 24, 2012 I don't see a pound sign, but if it's commenting out the line then it's not part of a string. The explode function takes a string as each parameter. Link to comment Share on other sites More sharing options...
ameliabob Posted April 24, 2012 Author Share Posted April 24, 2012 The line should have read $a = explode( " ",$s) This didn't split apart the line. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 24, 2012 Share Posted April 24, 2012 If you want to split on a tab, use "\t". Link to comment Share on other sites More sharing options...
ameliabob Posted April 24, 2012 Author Share Posted April 24, 2012 For some reason the string trying to do the explode doesn't seem to get posted to the forum. The character to do the explode is the tab character 0x09. I tried to use the HTML notation of followed with a semicolon and enclosed the whole thing in quotes. Keying this in the message or enclosing it in a codebox won't take on the forum Link to comment Share on other sites More sharing options...
ameliabob Posted April 24, 2012 Author Share Posted April 24, 2012 For some reason the string trying to do the explode doesn't seem to get posted to the forum. The character to do the explode is the tab character 0x09. I tried to use the HTML notation of followed with a semicolon and enclosed the whole thing in quotes. Keying this in the message or enclosing it in a codebox won't take on the forum Link to comment Share on other sites More sharing options...
justsomeguy Posted April 25, 2012 Share Posted April 25, 2012 That's fine, just use "\t" in PHP to represent a tab character. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now