Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gisoreb/php_reverse_string_interview_code
PHP function to reverse a string.
https://github.com/gisoreb/php_reverse_string_interview_code
Last synced: 6 days ago
JSON representation
PHP function to reverse a string.
- Host: GitHub
- URL: https://github.com/gisoreb/php_reverse_string_interview_code
- Owner: GisoreB
- Created: 2024-08-20T10:19:42.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-20T10:23:49.000Z (3 months ago)
- Last Synced: 2024-08-20T12:31:45.101Z (3 months ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## PHP Reverse String Function
We can also reverse a string using recursion and substr() function. The substr() function is used to get a substring of the original string.
Here we have defined a function Reverse() with the string passed as argument. During every recursive call, we have used the substr() method to extract the first character of argument string and called the Reverse() function again by passing remaining part of string as argument and concatenated the first character at the end of the string returned from current call.## Screenshot
![Screenshot 2024-08-20 131642](https://github.com/user-attachments/assets/e172dc5f-e977-4cef-81e9-c57802822be3)