html - PhP pulling string from line and separating by ":" -


i trying pull string .txt file using php, have done using code:

$f_contents = file("accounts/00183.txt"); $line = $f_contents[array_rand($f_contents)]; $data = $line; 

after random string pulled separated.

e.g strings in .txt in format "user:pass".

im trying make "$first" = content before ":" e.g "user". , "$last" = content after ":" e.g "pass".

i'v looked around on google 2 hours , found nothing works. hope can help!

use list & explode -

$str = "user:pass";  list($first, $last) = explode(':', $str); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -