Created
October 31, 2014 01:26
-
-
Save aisin/d4dca593c278775b8607 to your computer and use it in GitHub Desktop.
PHP 字符串转数组
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//explode用法: | |
$var = '10, 24, 29, 32, 56'; | |
$ary = explode(",", $var); | |
print_r ( $ary ); // Array ( [0] => 10 [1] => 24 [2] => 29 [3] => 32 [4] => 56 ) | |
//str_split用法:一般用于固定字符数分隔 | |
$strs = 'abcdefg'; | |
$arys = str_split($strs, 2); | |
print_r ( $arys ); // Array ( [0] => ab [1] => cd [2] => ef [3] => g ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment