943,923 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1557
  • PHP RSS
Jul 26th, 2006
0

how to manipulate characters in strings

Expand Post »
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...
PHP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 12
Solved Threads: 1
Junior Poster
tefflox is offline Offline
174 posts
since Jul 2006
Jul 27th, 2006
0

Re: how to manipulate characters in strings

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.
Reputation Points: 23
Solved Threads: 23
Posting Pro in Training
Puckdropper is offline Offline
494 posts
since Jul 2004
Jul 27th, 2006
0

Re: how to manipulate characters in strings

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
Reputation Points: 12
Solved Threads: 1
Junior Poster
tefflox is offline Offline
174 posts
since Jul 2006
Jul 27th, 2006
0

Re: how to manipulate characters in strings

for($i = 0; $str[$i] != ""; $i++) ---works great, thanks! :-)
Last edited by tefflox; Jul 27th, 2006 at 11:24 am.
Reputation Points: 12
Solved Threads: 1
Junior Poster
tefflox is offline Offline
174 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PDF to HTML conversion--php
Next Thread in PHP Forum Timeline: Same problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC