Page 1 of 1

Substring

Posted: Sun Jul 04, 2004 12:09 pm
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

Posted: Sun Jul 04, 2004 12:19 pm
by markl999

Code: Select all

$string = 'This is a test';
$string1 = substr($string, 5, 2);

Posted: Sun Jul 04, 2004 12:21 pm
by mshita
Thank you Mark!