I have inputted a word from a user and i want to find that word in a text file.
My text file is like this.
--------------
name1:value1
name2:value2
name3:value3
...
...
--------------
So if my user inputs name1 so i want corresponding value1..
How can i do these? Can anyone help me..??

kirtan_thakkar
Recommended Answers
Jump to Post<?php function find_value($input) { // $input is the word being supplied by the user $handle = @fopen("/users/edwin/list.txt", "r"); if ($handle) { while (!feof($handle)) { $entry_array = explode(":",fgets($handle)); if ($entry_array[0] == $input) { return $entry_array[1]; } } fclose($handle); } return NULL; } ?>
All 9 Replies
edwinhermann
57
Junior Poster

kirtan_thakkar
trickist17
0
Newbie Poster
edwinhermann
57
Junior Poster
trickist17
0
Newbie Poster
edwinhermann
57
Junior Poster
diafol
commented:
welcome back
+14
trickist17
0
Newbie Poster
edwinhermann
57
Junior Poster
trickist17
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.