php - Newline In File -


i got problem... have php script named getdata.php

 <?php      $filename = "data";     $data = file_get_contents($filename);     $data = explode("\n", $data);      print_r($data); ?> 

and data file

name admin\nname guest 

when run php code get:

array ( [0] => name admin\nname guest )  

i want output

array ( [0] => name admin [1] => name guest )  

what should do?

change this

    $data = explode("\n", $data); 

to

    $data = explode("\\n", $data); 

the issue in data file \n string of 2 characters \ , n, in explode invocation single control character \n. changing \\n it's same 2 characters data


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -