Jeremy Sayers
Jeremy Sayers

Reputation: 637

Looping through text and putting each line in an array PHP

so I have created a Shell command that is executed using PHP, and it returns something like this:

deathletsgo
lordhaigh
pampos
cheese510
TheLoneRanger6

And I've been trying to find a way to loop through and put each name in a different value in an array, so like Servers[0] would contain deathletsgo and Servers[1] would contain lordhaigh, etc, any ideas?

Thanks!

Upvotes: 1

Views: 329

Answers (1)

John Conde
John Conde

Reputation: 219874

$string = "deathletsgo
lordhaigh
pampos
cheese510
TheLoneRanger6";
$servers = explode("\n", $string);

Upvotes: 3

Related Questions