Page 1 of 1

What function(s) do I use?

Posted: Mon Jun 14, 2010 4:56 pm
by tonykasdorf
I would like to take a string and remove the first 5 characters from the string. I would like to have the remaining portion of the string returned (not the first 5 characters). I want to do the same thing with the end of the string except remove the last 16 characters.

What two functions would I use to do this?

Re: What function(s) do I use?

Posted: Mon Jun 14, 2010 7:14 pm
by JakeJ
preg_replace()

Re: What function(s) do I use?

Posted: Tue Jun 15, 2010 9:10 am
by AbraCadaver
Why two functions? Is this a test question or something?

Code: Select all

substr()

Re: What function(s) do I use?

Posted: Tue Jun 15, 2010 9:27 am
by timWebUK
AbraCadaver wrote:Why two functions? Is this a test question or something?

Code: Select all

substr()
I think that is just the way he has phrased it as he asked two questions - not realising that one function is suitable for both problems.

Re: What function(s) do I use?

Posted: Tue Jun 15, 2010 9:37 am
by dimxasnewfrozen
Would also work

Code: Select all

 explode() 

Re: What function(s) do I use?

Posted: Tue Jun 15, 2010 9:43 am
by AbraCadaver
dimxasnewfrozen wrote:Would also work

Code: Select all

 explode() 
How so?