What function(s) do I use?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tonykasdorf
Forum Newbie
Posts: 6
Joined: Wed Mar 31, 2010 7:13 am

What function(s) do I use?

Post 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?
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: What function(s) do I use?

Post by JakeJ »

preg_replace()
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: What function(s) do I use?

Post by AbraCadaver »

Why two functions? Is this a test question or something?

Code: Select all

substr()
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: What function(s) do I use?

Post 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.
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

Re: What function(s) do I use?

Post by dimxasnewfrozen »

Would also work

Code: Select all

 explode() 
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: What function(s) do I use?

Post by AbraCadaver »

dimxasnewfrozen wrote:Would also work

Code: Select all

 explode() 
How so?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply