[SOLVED] Substring

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
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Substring

Post by mshita »

Hi,

What is the php equivalent to Java's substring?

In Java:

String str = "This is a test";
String str1 = str.substring(5, 7); <- Puts "is" into str1

How do I do this in PHP?

Cheers,
Mounir
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Code: Select all

$string = 'This is a test';
$string1 = substr($string, 5, 2);
mshita
Forum Commoner
Posts: 32
Joined: Sat Jul 03, 2004 8:55 pm
Location: Portland, OR
Contact:

Post by mshita »

Thank you Mark!
Post Reply