I have an array which the format is as followed:
Array
(
[1] =>
Status Name DisplayName
[2] =>
------ ---- -----------
[3] =>
Running ADWS Active Directory Web Services
)
There is no key of the value of 0
as this is unset prior to displaying the Array, this array is generated from a text file:
$File = utf8_encode(file_get_contents("Services.txt"));
Now, Lets take the third key within this array:
[3] =>
Running ADWS Active Directory Web Services
How would I explode at tab space so I get:
array
(
[1] => Running
[2] => ADWS
[3] => Active Directory Web Services
)
I am currently exploding at a white space, which is generating the wrong output... How would I go about this?
Using a regex I get the following:
preg_split('/\s+/', $String);
Array
(
[0] => Array
(
[0] =>
[1] => Running
[2] =>
[3] => ADWS
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
[12] =>
[13] =>
[14] =>
[15] =>
[16] =>
[17] =>
[18] => Active
[19] => Directory
[20] => Web
[21] => Services
[22] =>
[23] =>
[24] =>
[25] =>
[26] =>
[27] =>
[28] =>
[29] =>
[30] =>
)
Using trim followed by explode(" ",$String);
or the regular expression posted above, returns a similar result, but with 20 keys instead of 30
using the answer posted, I have got the following:
[0] => Array
(
[0] =>
Running ADWS Active Directory Web Services
)
which is not as expected