How to remove anything in a string after “-”?

后端 未结 7 945
迷失自我
迷失自我 2020-12-23 15:05

This is the example of my string.

$x = \"John Chio - Guy\";
$y = \"Kelly Chua - Woman\";

I need the pattern for the reg replace.

         


        
相关标签:
7条回答
  • 2020-12-23 15:38

    You could use strtok:

    $x = strtok($x, '-');
    
    0 讨论(0)
提交回复
热议问题