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

What are the features of object-oriented programming in php?

725


Why is php used?

787


Which function would you use to read a line of data from a file in php?

835


How can we access the data sent through the url with the post method?

738


How to get length of an array in PHP?

779


Difference between array_combine and array_merge?

776


What is a namespace in php?

737


What are variables in research examples?

837


What is the difference between exception::getmessage and exception::getline?

767


Does session expire on closing browser?

716


Is php case sensitive?

722


What is the definition of a session?

781


How can I use single quotes in single quotes in php?

697


What is trait in php?

763


Write the statements that are used to connect php with mysql

761