Jump to content

Archived

This topic is now archived and is closed to further replies.

dtyson2000

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

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I'm not seeing why you'd need an array to do this at all.
[code]$new_word=$existing_word . $letters;[/code]
Is that what you're trying to do?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Just to let you guys know:

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.