As you can no doubt deduce from the replies that you have received so far, your requirements remain vague. The question implied by your title, "check if an element exists in array", has been more than adequately dealt with. But from your later comments, this is not what you really want.
Please correct me if I'm wrong, but it seems to me that your real requirements are as follows:
What is not clear, however, is what output you want if the name occurs more than once in the file, ie for input of 'Jim' in your example, I see several possibilities:
Jim 12 # Use first occurrence Jim 57 # Use last occurrence Jim 12, 57 # List of all numbers associated with Jim Jim 69 # Jim's total 'score' Sorry, name 'Jim' occurs more than once # Or some similar warning
Based on the answers provided above, you should be able to code for any of these. What I suggest is that you now write some code, and come back to us if you still can't get it to do what you want. But please, in that case, tell us what it is that you want!
In reply to Re: check if an element exists in array
by Not_a_Number
in thread check if an element exists in array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |