SHARE
TWEET

Untitled

a guest Dec 11th, 2013 32 Never
  1. if($fh == "Harry") {
  2. $password = "123456";
  3. }
  4.        
  5. "Harry":"12345","Biswas":"789456","garry":"56894"
  6.        
  7. $str = '"Harry":"12345","Biswas":"789456","garry":"56894"';
  8.  
  9. $passwords = array();
  10. foreach( str_getcsv( $str) as $entry) {
  11.     list( $name, $pw) = explode( ':', $entry);
  12.     $passwords[$name] = $pw;
  13. }
  14.        
  15. $fh = "Harry";
  16. echo $passwords[$fh]; // 12345
  17.        
  18. $data = file_get_contents("userpass.txt");
  19.  $records = explode(",", $data);
  20.  
  21.  foreach ($records as $record) {
  22.     $record = preg_replace('/"/', "", $record);
  23.     $userpass = explode(":", $record);
  24.  
  25.     //DO YOUR SQL STATMENT HERE
  26.  
  27.     $sql = "INSERT INTO user (username, `password`) VALUES ('" . $userpass[0] . "','" . $userpass[1] . "')";
  28.     //execute query
  29.  }
RAW Paste Data
Top