This forum is now read-only. Please use our new forums at

Functions, Part I Forum

View Course » View Exercise

500 points
Submitted by
Nneka Udeagbala
over 1 year ago

Substring letters

I typed my substring as:
$myname = "Nneka";
$partial = substr($myname, 1, 4);
print $partial;

and it printed "neka".

Why did it print the a?

If I type:
$myname = "Nneka";
$partial = substr($myname, 0, 4);
print $partial;

It would print "Nnek".

1 vote


You need to do

$partial = substr($myname, 0, 5);

903 points
Submitted by
over 1 year ago