/    Sign up×
Community /Pin to ProfileBookmark

parsing a string

Okay, I’m working on a funny little password, salt type thing which is way more complicated than I need it to be but I think it’s clever. I want to get the first 3 digits that are less than 5 out of an md5 hash. I want them stored as separate values in an array.

I can’t figure out how to split a string into it’s separate characters though.

oh dear. that was easy. nevermind.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Feb 28.2007 — A string is an array of characters - always.

You can address each position in a string as you would an array:[code=php]<?php
$user = "aj_nsc";
echo $user[0] . $user[2] . $user[4];
?>[/code]
Copy linkTweet thisAlerts:
@aj_nscauthorFeb 28.2007 — thats something I never knew. thanks.
×

Success!

Help @aj_nsc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...