Jump to content


Photo

To "Array" or not to "Array".. THAT is the question


  • Please log in to reply
5 replies to this topic

#1 dtyson2000

dtyson2000
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 11 July 2006 - 08:21 PM

Hi Folks...

I'm not sure what I should do in this instance. So I'd like some input from the professionals.

I am setting up a little script that will take a word (set as a variable) and alter its spelling by adding some letters to the end of that word (variable). The endings to be added to each word are constant and will not change.

Is this something you would do with an array or is it best to just create another set of variables representing each ending? Which is the simplest way to go?

Thanks a lot!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 July 2006 - 08:25 PM

Use an array. I think that would be the easiest way to go. You can use a foreach() loop to append the letters to the word.

#3 robos99

robos99
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 11 July 2006 - 08:27 PM

I'm not seeing why you'd need an array to do this at all.
$new_word=$existing_word . $letters;
Is that what you're trying to do?

#4 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 11 July 2006 - 08:29 PM

i believe he has a series of different "endings" that can be appended to a word, in which case it's likely easier putting them all in an array and picking/choosing which ones he wants to use.

#5 dtyson2000

dtyson2000
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 11 July 2006 - 08:33 PM

That's exactly right. The endings are all different. I'll try with the array. Thanks guys!

#6 dtyson2000

dtyson2000
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 12 July 2006 - 05:10 AM

Just to let you guys know:

I used an array and it works perfectly. Thanks a lot for your help!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users