dtyson2000 Posted July 11, 2006 Share Posted July 11, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/14326-to-array-or-not-to-array-that-is-the-question/ Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14326-to-array-or-not-to-array-that-is-the-question/#findComment-56442 Share on other sites More sharing options...
robos99 Posted July 11, 2006 Share Posted July 11, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/14326-to-array-or-not-to-array-that-is-the-question/#findComment-56443 Share on other sites More sharing options...
akitchin Posted July 11, 2006 Share Posted July 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/14326-to-array-or-not-to-array-that-is-the-question/#findComment-56444 Share on other sites More sharing options...
dtyson2000 Posted July 11, 2006 Author Share Posted July 11, 2006 That's exactly right. The endings are all different. I'll try with the array. Thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/14326-to-array-or-not-to-array-that-is-the-question/#findComment-56447 Share on other sites More sharing options...
dtyson2000 Posted July 12, 2006 Author Share Posted July 12, 2006 Just to let you guys know:I used an array and it works perfectly. Thanks a lot for your help! Quote Link to comment https://forums.phpfreaks.com/topic/14326-to-array-or-not-to-array-that-is-the-question/#findComment-56599 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.