join array values and with a hyphen in php

前端 未结 2 1919
無奈伤痛
無奈伤痛 2021-01-29 11:41

i have array like this :

$year = Array(
     [0] => 2019
     [1] => 2020
    );

i want to join this two array and the array values separ

相关标签:
2条回答
  • 2021-01-29 12:31

    Everything is already invented:

    echo implode('-', $split);
    
    0 讨论(0)
  • 2021-01-29 12:34

    Use implode:

    $array = array(
        0 => 2019, 1 => 2020
    );
    
    $string = implode('-',$array);
    echo $string;
    
    0 讨论(0)
提交回复
热议问题