I have a text file that serves as a simple database, each entry spanning two lines, like so:
name
number
bob
39
jack
22
jill
85
Now say that I have each line separated in an array, and I wanted to analyze each NAME and see if it equals a variable. Would it be faster to do this:
if($variable == $line) {
//true
}
Or first filter out the even numbered lines (the names), and then analyze them to see if they equal the variable? If you don't know, the first line following basically finds the remainder of the count (this is all in a foreach loop) divided by 2, and if it equals 0 then it is an even number.
if ($count%2 == 0) {
if($variable == $line) {
//true
}
}
Thanks.