how to get substring of string without using substr() function in php ????

Answer Posted / abhijit sil

Accessing single characters in a string can be achived
using "curly braces"
<?php

$string = 'abcdef';
echo $string{0}; // a
echo $string{3}; // d
echo $string{strlen($string)-1}; // f

?>

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to generate a form?

607


What are the common uses of php?

546


Is string php function?

565


Tell me how to set a page as a home page in a php based site?

498


How To Get the Uploaded File Information in the Receiving Script?

577






Explain the difference between $message and $$message?

545


Can a super () and this () keywords be in same constructor?

478


What is the function of mysql_real_escape_string in php?

471


What is the best practice for running mysql queries in php? Consider the risk of sql injection.

543


What is the use of strip_tags() method?

543


Does php need html?

529


Can I use php in html?

551


What are the differences between GET and POST methods?

528


What is difference between put and post method in http?

473


What is meant by pear in php? What is the purpose of it?

517