Forum : php
Brief description  about Online courses   join in Online courses
View Karm jeet singh 's Profile

php

how to Create a string “this is a test”. Display the first, third and last characters of this string.
Asked by Karm jeet singh | Nov 19, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Karmjeet,

check out the fallowing example

<?php
//To Create a string
$str = 'This is a test.';

//To Get the first character of a string
$first = $str[0];

//To Get the third character of a string
$third = $str[2];

//To Get the last character of a string.
$last = $str[strlen($str)-1];

?>
Nov 23, 2010