Added PHP Substring Function to Guide. (#33826)
* Added PHP Substring Function to Guide. * Added PHP Substring Function to Guide. * Fixed typo
This commit is contained in:
committed by
Randell Dawson
parent
463acd85e8
commit
9526a6ed03
44
guide/english/php/substring/index.md
Normal file
44
guide/english/php/substring/index.md
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
title: subtring
|
||||
---
|
||||
|
||||
## Substring Function in PHP
|
||||
|
||||
The Substring function in PHP returns a portion of the string, specified by two parameters, the start and the length.
|
||||
|
||||
|
||||
## Syntax
|
||||
|
||||
The substring function is used like any other function in php, and uses the subtr() syntax.
|
||||
|
||||
|
||||
```
|
||||
<?php
|
||||
|
||||
subtr( $string, $start, $length);
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
Below is an example of how you could use the substring function in a real world situation:
|
||||
|
||||
```
|
||||
<?php
|
||||
|
||||
$apple = 'Apple';
|
||||
$alphabet = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
substr($apple, 0, 5); // Apple;
|
||||
substr($apple, 0, 3); // App;
|
||||
substr($apple, 3, 2); // le;
|
||||
substr($alphabet, 0, 26); // abcdefghijklmnopqrstuvwxyz;
|
||||
substr($alphabet, 12, 6); // mnopqr;
|
||||
|
||||
```
|
||||
|
||||
## Additional Info
|
||||
|
||||
For more information, please see [PHP: Substring](http://php.net/manual/en/function.substr.php)
|
Reference in New Issue
Block a user