I have a text file which has got several names in it example:
mathew
james
kelvin
peter
jackson
linak
thomas
the main code is given below:
$names = file(names.txt);
foreach ( $names as $name) {
//then this call to a function
$data = 'localhost/q?detail='.$name;
//////do some code etc..
//insert into table
}
my problem is it calls like localhost/q?detail=mathew%0A
and next localhost/q?detail==%0D%0A and next localhost/q?detail=james%0A
How do I get rid of those %0D%0A things?
Those are line terminators (or separators; depending on how you look at it) and are included by default in the items returned by
file(), as the documentation states:To remove them, simply pass the
FILE_IGNORE_NEW_LINESflag tofile():So in your code just do the following: