Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Southern Oregon
    Posts
    239
    Thanks
    56
    Thanked 1 Time in 1 Post

    split a string with no spaces to an array?

    I want to split a string of ascii characters with no spaces into an array of individual characters.

    I looked at the php manual and found that explode() will not accept an
    empty string as a delimiter.

    So I am trying
    PHP Code:
    $this->shrtCodeLst explode(' 'str_replace(''' '$this->codeStr));
     print  
    str_replace(''' '$this->codeStr); //testing:  prints string without spaces 
    I also look back at the str_replace() entry in the manual and it does not
    say anything about empty string for search parameter.
    So... Are there any suggestions, inside info, etc here?
    I am writing code to generate a captcha graphic and want to apply
    some choice to the amount and configuration of the characters in
    the string.

    Unless I have been blind to a dumb typo, I seem to remember having
    done this successfully elsewhere in php v5 code (use empty string as
    search parameter in str_replace())

    Thanks for time and attention

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    PHP Code:
    $a str_split($this->codeStr); 
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  3. Users who have thanked Fou-Lu for this post:

    anotherJEK (02-06-2013)

  4. #3
    Regular Coder
    Join Date
    Aug 2010
    Location
    Southern Oregon
    Posts
    239
    Thanks
    56
    Thanked 1 Time in 1 Post

    Thank you

    That rings a bell.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •