how to manipulate characters in strings

Reply

Join Date: Jul 2006
Posts: 174
Reputation: tefflox is an unknown quantity at this point 
Solved Threads: 1
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

how to manipulate characters in strings

 
0
  #1
Jul 26th, 2006
i'm unsure if i need to use an array (i'm a newbie to php, the most i've done is make text appear in random color)... anyhow, i want to pass a string to a function that will decrement a color value for each character. here is what i have so far...
  1. <?
  2. function red($str) {
  3. $red = rand(60, 99)
  4. /** first 2 of the six hex code numbers
  5.   * the other 4 will be light grey (neutral)
  6.   * so the string will fade or darken
  7.   * from the first red value
  8.   **/
  9.  
  10. for (....) // need help here !
  11.  
  12. echo(....) // i've got this part figured
  13. }
thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 494
Reputation: Puckdropper is an unknown quantity at this point 
Solved Threads: 21
Puckdropper Puckdropper is offline Offline
Posting Pro in Training

Re: how to manipulate characters in strings

 
0
  #2
Jul 27th, 2006
for ($i = 0; $i< MAXLOOPS; $i++)

or you could use a NULL string in an array to indicate the end and get this:

while ($string[$i] != "") ($i is the string you're looking at now)

I'm not 100% sure about the code working, but the idea is sound.
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 174
Reputation: tefflox is an unknown quantity at this point 
Solved Threads: 1
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

Re: how to manipulate characters in strings

 
0
  #3
Jul 27th, 2006
thanks, i will work with your code. it looks easy the way you have written it, while the tutorials for php arrays seem really obscure.

tho i did realize it's 100% easier to just make an <img src...> file to do what i had in mind.

but i'm learning :-) thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 174
Reputation: tefflox is an unknown quantity at this point 
Solved Threads: 1
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

Re: how to manipulate characters in strings

 
0
  #4
Jul 27th, 2006
for($i = 0; $str[$i] != ""; $i++) ---works great, thanks! :-)
Last edited by tefflox; Jul 27th, 2006 at 11:24 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC