How to convert an integer to an array in PHP?

前端 未结 4 417
小鲜肉
小鲜肉 2020-12-03 17:43

What would be the most simple way to convert an integer to an array of numbers?

Example:

2468 should result in array(2,4,6,8).

4条回答
  •  一个人的身影
    2020-12-03 18:27

    Example #2 Splitting a string into component characters

    $str = 'string';
    $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
    

提交回复
热议问题