PHP: str_split() function
The str_split() function is used to convert a string to an array.
(PHP 5 )
|string_name||The string to be split.||Required||String|
|split_length||The length of the chunk.||Optional||Integer|
If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise, each chunk will be one character in length.
FALSE is returned if split_length is less than 1.
If the split_length length exceeds the length of the string, the entire string is returned as the first (and only) array element.
Value Type: Array.
<?php $string_name='Welcome to w3resource.com'; print_r(str_split($string_name)); echo '<br>'; print_r(str_split($string_name,4)); echo '<br>'; ?>
Array (  => W  => e  => l  => c  => o  => m  => e  =>  => t  => o  =>  => w  => 3  => r  => e  => s  => o  => u  => r  => c  => e  => .  => c  => o  => m ) Array (  => Welc  => ome  => to w  => 3res  => ourc  => e.co  => m )
PHP: Tips of the Day
Finding the number of days between two dates
$now = time(); // or your date as well $your_date = strtotime("2010-01-31"); $datediff = $now - $your_date; echo round($datediff / (60 * 60 * 24));
Ref : https://bit.ly/2ZDZ4as
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework