You can use str_split
and intval
:
$number = 2468;
$array = array_map('intval', str_split($number));
var_dump($array);
Which will give the following output:
array(4) {
[0] => int(2)
[1] => int(4)
[2] => int(6)
[3] => int(8)
}
More Related Contents:
- Convert result to a array [closed]
- How to convert array to SimpleXML
- How to get a form input array into a PHP array
- List of Big-O for PHP functions
- Array to String PHP?
- recursive array_diff()?
- How to access mysql result set data with a foreach loop
- How to insert an item at the beginning of an array in PHP?
- php: check if an array has duplicates
- Best way to transfer an array between PHP and Javascript [duplicate]
- How to skip the 1st key in an array loop?
- How can you make a multidimensional array unique? [duplicate]
- How to use php array with sql IN operator? [duplicate]
- How to access a property of an object (stdClass Object) member/element of an array? [duplicate]
- PHP curly braces in array notation
- Explode string into array with no empty elements?
- Group 2d array rows by one column and sum another column [duplicate]
- PHP: Get the key from an array in a foreach loop [duplicate]
- Merging two arrays with the “+” (array union operator) How does it work?
- Group 2d array data by one column and sum other columns in each group (separately)
- Find min/max in a two dimensional array
- foreach with three variables add
- Generate URL with parameters from an array
- How to cast variable to array
- PHP array, Are array indexes case sensitive?
- Most efficient way to search for object in an array by a specific property’s value
- Implementing a simple lookup array
- Sort a multidimensional array descending by subarray count and preserve first level keys
- How are associative arrays implemented in PHP?
- Why does PHP not complain when I treat a null value as an array like this?