当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Split characters from string

问题描述:

I have a string which contain contact numbers. For example,

$contactnumber='923216210221'

Now I want to separate starting 5 digits e.g. '92321' in a different variable and other digit e.g. '6210221' in a different variable.

网友答案:

Use substr PHP:

$partOne = substr($contactnumber, 0, 5);
$partTwo = substr($contactnumber, 6);
网友答案:

$partTwo = substr($contactnumber,5);

分享给朋友:
您可能感兴趣的文章:
随机阅读: