How to reverse a string in php without using inbuilt predefined function
Whatsapp
https://fundaofwebit.com/post/how-to-reverse-a-string-in-php-without-using-predefined-function
How to reverse a string in php without using predefined function.
In this post, you will be learning about how to reverse a string in php without using any inbuilt function in php.
So guys, now let's begin with reversing a string in php where we are not using any default or predefined function of php like, strrev() and strlen().
<?php
$string = "ved";
$string_lenght = 0;
while($string[$string_lenght] != null){
$string_lenght++;
}
$string_lenght; //Total String Lenght
//$string_lenght = strlen($string);
for ($i=($string_lenght-1); $i >= 0; $i--)
{
echo "Reversed String : ". $string[$i];
}
?>
Output:
Reversed String : dev
Thanks for reading.
© Copyright - 2018 - 2023 | All rights reserved at Funda of Web IT