Linux Ubuntu move file from one directory to another directory command

November 26, 2014

In Linux, type: To move file mv somefile /anotherfolder/ To move all folder content: mv /somefolder/* /anotherfolder/* In Ubuntu, type: To move file sudo mv somefile /anotherfolder/ To move all folder content: sudo mv /somefolder/* /anotherfolder/* There’s almost always more than way to do something in Linux. And more importantly, there are almost always caveats. […]

PHP fgetcsv count lines end of file, eof

November 17, 2014

Due to fgetcsv read only a line from open file, or line by line if looping. As decribe below, it doesn’t able to return number of line from specific file. The fgetcsv() function parses a line from an open file, checking for CSV fields. The fgetcsv() function stops returning on a new line, at the […]

PHP check string exist in string

November 17, 2014

The correct way to write the statement to check if string contains specific words is use strpos function. Strpos is used to find the occurrence of one string inside other. Note that the use of !== false is deliberate; strpos returns either the offset at which the needle string begins in the haystack string, or […]

Ubuntu user management command line

November 14, 2014

Change user password To change self password #passwd To change other user password #passwd username Removes the user’s home directory as well as deleting the user #sudo userdel -r [username] Add new user: #sudo adduser <username> Add user to admin #sudo adduser <username> admin Add user to sudoer #visudo Switch user sudo <username>

PHP dealing with commas in CSV data

November 12, 2014

Look carefully the data, there are multiple commas ‘,’ inside the address field. When transform the data to array, the output will be each commas separated in one array value. Example: (wrong way) Don’t attempt to do this with a regular expression. Just use str_getcsv()! The third parameter informs str_getcsv() to look for quote-enclosed fields. […]