Str (Menampilkan sebagian dari deretan data)

Ketik kode berikut :
$str=”phone”; echo strtoupper ($str);

PHONE

$str=”Welcome to Interactive PHP”; $first = substr($str, 0, 1); echo $first;
W
$str=”Welcome to Interactive PHP”; $first_word=substr($str, 0, 7); echo $first_word;
Welcome

$str=”Welcome to Interactive PHP”; $last_word=substr($str, -3); echo $last_word;
PHP
 $str=”I love PHP”; $new_str=str_replace(“I”, “You”, $str); echo $new_str;
You love PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s