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 is csrf validation?

776


What does nan stand for computer science?

734


What is the use of offset in mysql?

714


Is laravel easy to learn?

719


Write a php function to convert all null values to blank?

1087


Explain how to submit form without a submit button.

736


Which software is used to run php programs?

721


How can you get the size of an image in PHP?

747


What is the difference between html and php?

728


Tell me how is it possible to know the number of rows returned in result set?

805


Does php need apache?

693


What the use of var_dump()?

812


Who is the father or inventor of php?

825


Suppose the variable $var1 is set to 10 and the $var2 is set to the character var1, what's the value of $$var2?

734


How big is nvarchar max?

772