NYCPHP Meetup

NYPHP.org

[nycphp-talk] Input as array names

Hall, Leam lhall at smartronix.com
Tue Aug 25 15:27:51 EDT 2009


 Okay, here's one of the places I don't really get and can use some help on. On my text processing script I'm going to slurp up host names. They come in as the first, counting from 0, element. I can explode and create the array, which gives me a string:

$hostname[1] = somehost.example.com

I can safely get rid of the ".example.com" bit, leaving $hostname[1] as "somehost". What I need to understand is how to take $hostname[1] and make it an array in it's own right so I can assign it a list of numbers. 

For example, my text file looks something like this:

Bug ID:  1234
Affected Machines:
  somehost1
  somehost2.example.com
  somehostwehavenotseeninyears.example.com

Bug ID:  3456
Affected Machines:
  somehost1
  somehostwehanvenotseeninyears.example.com

At the end I need to print out something like this:

somehost1:  1234, 3456
somehost2:  1234
somehostwehavenotseeninyears:  1234 3456

Recommendations for a neophyte PHP'r?

Thanks!

Leam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090825/9f897f27/attachment.html>


More information about the talk mailing list