gos1 Posted December 13, 2006 Share Posted December 13, 2006 Hi ; I need to just take all the uıser id's from a CSV file. All the fields are seperated by ";" and in front of the id's there is a line break (a rectangle). Does anyone know how to ? ?? Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted December 13, 2006 Share Posted December 13, 2006 Use the file and explode functions.http://www.php.net/filehttp://www.php.net/explodeor fgetcsv.http://www.php.net/fgetcsvThe latter has a user provided function that might work for you:http://us2.php.net/manual/en/function.fgetcsv.php#70957 Quote Link to comment Share on other sites More sharing options...
gos1 Posted December 13, 2006 Author Share Posted December 13, 2006 but I am trying to just take the id. I mean the algorithm is going to be like : for every line take the value until the first comma and if the value is integer store it in somewhere.. Is it possible ?? Quote Link to comment Share on other sites More sharing options...
mainewoods Posted December 13, 2006 Share Posted December 13, 2006 preg_match_all() is what you want:http://www.php.net/manual/en/function.preg-match-all.php--the function returns an array of matches so will do all the work for you but you will have to break the ice with regular expressions--regular expression can look for matches only at the beginnings of lines like you want but you have to set flags to do that. a good online regular expression tutorial I use:http://www.regular-expressions.info/ Quote Link to comment Share on other sites More sharing options...
gos1 Posted December 13, 2006 Author Share Posted December 13, 2006 I still cannot find the beginning of the line function ? Does anyone have the code for that ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.