gsmith Posted January 8, 2006 Share Posted January 8, 2006 I thought I knew how to do this, but things aren't working. I'm trying to reference a certain value in an array, without knowing ahead of time the exact key. So I've got: $usersname=$_POST["username"];//Find the array pointer for this user$c=1;foreach ($uname as $value) { if ($usersname != $value) { $c++; } else { break; } }print_r($uname[$c]); But it won't print anything at the end! If I hardcode in a value for $c in the print_r statement (put a 2 in there for instance) it works...but it won't work with $c! Any help please? Link to comment Share on other sites More sharing options...
Selacius Posted January 8, 2006 Share Posted January 8, 2006 maybe try echo $uname[$c]; Link to comment Share on other sites More sharing options...
gsmith Posted January 8, 2006 Author Share Posted January 8, 2006 It was my fault.I forgot to reference one of the earlier variables correctly. I hate those programmer-induced errors - and aren't they all?! Link to comment Share on other sites More sharing options...
DooVoo Posted January 9, 2006 Share Posted January 9, 2006 <MAJOR EDIT>Might help if I had read your "I've fixed it" reply </MAJOR EDIT> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now