php explode function for only first white space

前端 未结 5 2070
执笔经年
执笔经年 2021-02-18 19:25

I have a String Hello This is a String. I need to explode it in PHP only for the First White Space. How is that possible?

5条回答
  •  长情又很酷
    2021-02-18 19:46

    An alternative to explode

    $str   = 'Hello This is a String';
    $parts = preg_split('/(\s)/', $str, PREG_SPLIT_DELIM_CAPTURE);
    

提交回复
热议问题