Count length of array and return 1 if it only contains one element

前端 未结 4 1937
轻奢々
轻奢々 2020-12-09 15:33
$cars = \"bmw\",\"audi\",\"volvo\",\"vw\"
echo $cars.length

returns 4, but

$cars = \"bmw\"

returns 3 because it

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 16:01

    declare you array as:

    $car = array("bmw")
    

    EDIT

    now with powershell syntax:)

    $car = [array]"bmw"
    

提交回复
热议问题