strpos - Get value from file - php -


let's have in text file:

author:mjmz author url:http://abc.co version: 1.0 

how can string "mjmz" if string "author"?

i tried solution question (php value text file) no success.

the problem may because of strpos function. in case, word "author" got two. strpos function can't solve problem.

split each line @ : using explode, check if prefix matches you're searching for:

$lines = file($filename, file_ignore_new_lines); foreach($lines $line) {     list($prefix, $data) = explode(':', $line);     if (trim($prefix) == "author") {         echo $data;         break;     } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -