shiro
shiro

Reputation: 944

PHP string with numbers seperated with spaces to array

I am trying to store a few variables (numbers) that are in a single string, in an array. Like, if I would use something like

"1 0 0 1 1 0 0 1 1"

to store every single number in an array, like:

numbers[i];

I am sure there is a PHP function for this, help is appreciated.

Upvotes: 0

Views: 76

Answers (1)

David Fritsch
David Fritsch

Reputation: 3731

You should be able to use $numbers = explode(' ', $string);. This will create an array based on the spaces as a separator.

More info here: http://www.php.net/manual/en/function.explode.php

Upvotes: 7

Related Questions