$data['subject']= "Languages > English";
//This is how I get the string before the symbol '>'.
$subject = substr($data['subject'], 0, strpos($data['subject'], "> "));
$data['subject'] = "Languages > English";
$data['subject'] = array_map('trim', explode('>', $data['subject'])); // Explode data and trim all spaces
echo $data['subject'][0].'<br />'; // Result: Languages
echo $data['subject'][1]; // Result: English
4条答案
按热度按时间luaexgnf1#
或使用爆炸:
jtw3ybtb2#
https://php.net/substr
但你应该看看爆炸:https://php.net/explode
bmvo0sr53#
如果您需要〉之前和之后的数据,我将使用分解。
bvuwiixz4#
你可以这么做,
1.字符串将转换为数组
1.然后保留数组的最后一个值