sandy1028 Posted August 23, 2007 Share Posted August 23, 2007 Hi, Please tell me how to count the number of columns in text file.... $lines='db.txt'; foreach ($lines as $line) { $text_line = explode(":" , $line); Quote Link to comment https://forums.phpfreaks.com/topic/66337-count-columns/ Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 $text_line = explode(":" , $line); $X = count($text_line); //<--$X will be the columns so for the whole file $X = 0; $lines='db.txt'; foreach ($lines as $line) { $text_line = explode(":" , $line); $X = $X+ count($text_line); } echo "$X: columns "; Quote Link to comment https://forums.phpfreaks.com/topic/66337-count-columns/#findComment-331855 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.