如何在 php 中获取字符串中的特定字符

How to Get specifit character in string in php

我想得到一个单词直到一个特定的字符,例如space。我尝试使用 substr 但我不能。

假设我有列数据:

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 个案例中获取字符串。

非常感谢

如果列是 space 分隔的,那么您可以使用分解并提取所需列的索引。

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

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

echo $rowCols[1]; // returns 3/14/2016
echo $rowCols[2]; // returns 13:46
$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