explode single variable in php

后端 未结 4 1972
旧巷少年郎
旧巷少年郎 2021-01-26 13:25

Here is what i have in php :

I need to do explode the given variable

$a = \"hello~world\";

I need to explode as

$first         


        
4条回答
  •  [愿得一人]
    2021-01-26 14:01

    If you know the number of variables you're expecting to get back (ie. 2 in this case) you can just assign them directly into a list:

    list($first, $second) = explode('~', $a);
    // $first = 'hello';
    // $second = 'world';
    

提交回复
热议问题