explode single variable in php

后端 未结 4 1976
旧巷少年郎
旧巷少年郎 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 13:53

    explode returns an array. explode will break the given string in to parts using given character(here its ~) and will return an array with the exploded parts.

    $a = "hello~world";
    $str_array = explode("~",$a);
    
    $first = $str_array[0];
    $second = $str_array[1];
    
    echo $first." ".$second;
    

提交回复
热议问题