Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Break up word into array
    text
    copied!<p>i've done plenty of googling and whatnot and can't find quite what i'm looking for...</p> <p>I am working on tightening up the authentication for my website. I decided to take the user's credentials, and hash/salt the heck out of them. Then store these values in the DB and in user cookies. I modified a script I found on the PHP website and it's working great so far. I noticed however when using array_rand, that it would select the chars from the predefined string, sequentially. I didn't like that, so I decided to use a shuffle on the array_rand'd array. Worked great.</p> <p>Next! I thought it would be clever to turn my user inputted password into an array, then merge that with my salted array! Well, I am having trouble turning my user's password into an array. I want each character in their password to be an array entry. IE, if your password was "cool", the array would be, Array 0 => c 1 => o 2 => o 3 => l, etc etc. I have tried word to split up the string then explode it with the specified break character, that didn't work. I figure I could do something with a for loop, strlen and whatnot, but there HAS to be a more elegant way.</p> <p>Any suggestions? I'm kind of stumped :( Here is what I have so far, i'm not done with this as I haven't progressed further than the explodey part.</p> <pre><code>$strings = wordwrap($string, 1, "|"); echo $strings . "&lt;br /&gt;"; $stringe = explode("|", $strings, 1); print_r($stringe); echo "&lt;br /&gt;"; echo "This is the exploded password string, for mixing with salt.&lt;hr /&gt;"; </code></pre> <p>Thank you so much :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload