php - Read textfile with delimiters at all lines -
i have textfile looks this:
name=arthur lastname=mcconnell age=43
what array this:
array ( [name] => arthur [lastname] => mcconnell [age] => 43 )
all appreciated.
$filename = 'info.txt'; //read file line-by-line array $contents = file($filename); //loop through each line foreach($contents $line) { //split = sign $temp_array = explode('=', $line); //rebuild new array $new_array[$temp_array[0]] = $temp_array[1]; } //print out array @ end testing var_dump($new_array);
Comments
Post a Comment