将单个Mysqli数据拆分为单独的变量

时间:2016-04-07 04:36:30

标签: php

是否可以拆分单个列数据并将其存储在不同的变量中?

SELECT telephone FROM contacts WHERE id='1';

电话的价值是XXX-XXX-XXXX

$first = '(first)';
$second= '(second)';
$third= '(third)';
$dash = '(dash)';

1 个答案:

答案 0 :(得分:0)

$telNumber = "123-345-6789";
$telArray = explode("-",$telNumber);

$first = $telArray[0]; //123
$second= $telArray[1]; //345
$third= $telArray[2];  //6789