How to get first n characters of a string in PHP
In this post we will give you information about How to get first n characters of a string in PHP. Hear we will give you detail about How to get first n characters of a string in PHPAnd how to use it also give you demo for it if it is necessary.
we are going to learn about how to get the first n characters of a string in PHP.
In PHP, strings are the sequence of characters, where the index of the first character is 0, the second character is 1, third character is 3 etc.
Get the first n characters of a string
To get the first n characters of a string, we can use the built-in substr() function in PHP.
Here is an example, that gets the first 3 characters from a following string:
<?phpecho substr("Google", 0, 3);?>Output:
"Goo"
In the example above, we have passed 0, 3 as an arguments to the substr() function. So, it begins the extraction at index 0 and extracts before the 3rd character of a string.
Syntax : substr(string, start, length)
The second argument is start index and third argument is length that means how many characters you need to get from the start index.
Hope this code and post will helped you for implement How to get first n characters of a string in PHP. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
How to revoke 'git add' before 'git commit' ?
In this post we will give you information about How to revoke 'git add' before 'git commit' ?. Hear we will give you detail about How to revoke 'git add' before 'git commit' ?And how to use it also give you demo for it if it is necessary.
Sometimes you need to undo your git file before you git comment command. Because you made a some misteck or wrong code and you did git add using "git add ." command then you think how to undo your code before git commit command. But you can do that using git reset command, if you need to undo all file Or you may need to undo just one then you can do using git reset command, you can see bellow command.
Example:
// For Spesific filegit reset
// For all files
git reset
Hope this code and post will helped you for implement How to revoke 'git add' before 'git commit' ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
