PHP ARRAY, there are many times the same valu inside -
i trying use csv file in php code. tried this:
if (($handle = fopen("licences/myfile.csv", "r")) !== false) { while (($data = fgetcsv($handle, 1000)) !== false) { $num = count($handle); $row++; ($cc=0; $cc < $num; $cc++) { $userline = explode(";",trim($data[$cc])); $users =$userline[$cc]; echo "</br>" . print_r($userline) . "</br>"; } } }
but output not expect. when print_r:
array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1 array ( [0] => gl [1] => ) 1 array ( [0] => papb1 [1] => ) 1 array ( [0] => res [1] => ) 1 array ( [0] => ecllit [1] => ) 1
it's repeating values again , again.
the content of "myfile.csv" is:
gl; papb1; res; ecllit;
and variable $users value:
glpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllitglpapb1resecllit
can me have values 1 time, if it's not in array @ least in $users. because have lot of users add in csv, want step work before writing users.
sorry if it's basic question or if haven't given enough informations or if not clear, first post :/
thanks future replies,
sellion
use updated.
your csv file needs this.
gl papb1 res ecllit
then use updated code below.
if (($handle = fopen("file.csv", "r")) !== false) { $line = 1; while (($data = fgetcsv($handle, 1000)) !== false) { echo "line # $line : " . $data[0] . "</br>"; $line++; } }
this give output below :
line # 1 : gl line # 2 : papb1 line # 3 : res line # 4 : ecllit
i hope looking for.
Comments
Post a Comment