2016-03-19 44 views
0

我想要一个单词,直到一个spesicif字符,示例空间。我试图使用substr,但我不能。如何获取字符串中的指定字符php

Assumming我有列数据:

1. 3/14/2016 13:46 

i would like to get 3/14/2016 and showing it. is that possible? 



2. 3/14/2016 13:46 
i would like to get 13.46 without date. is that possible? 

有人可以告诉我如何从上述2的情况下得到的字符串。

非常感谢

+0

你看看'的strtotime()' – user3284463

回答

0

如果列空格分隔的,那么你可以使用一个爆炸,其中拉你想要的列的索引。

$rowData = "1. 3/14/2016 13:46"; 

$rowCols = explode(" ",$rowData); 

echo $rowCols[1]; // returns 3/14/2016 
echo $rowCols[2]; // returns 13:46 
0
$specifidCharacter = " " //Space for example 
$string = "1. 3/14/2016 13:46"; 

$tmp = explode($specificCharacter, $string); 
echo $tmp[1] //Case 1 
echo $tmp[2] //Case 2 
相关问题