Create a List of files within a certain directory

This function will list files and directories within a specified directory

E.g. if a directory named web contains some files like index.htm, contactus.htm and some folders like images, documents, products
The script will return

  • index.htm
  • contactus.htm
  • images
  • documents
  • products

$sortflag can be any of below
SORT_REGULAR – compare items normally (don’t change types)
SORT_NUMERIC – compare items numerically
SORT_STRING – compare items as strings
SORT_LOCALE_STRING – compare items as strings, based on the current locale.

PHP – MySQL Search on multiple columns using concat

More often there is a need to search part of a text in multiple columns and the search is based on a single keyword text box

For e.g. in a users table first name and last name can be stored in seperate columns

Let’s assume a user named Joe Smith stored in a users table with

first _name => Joe

last_name => Smith

If we have a single keyword text box search and if someone types “Joe Smith” and performs a search, a simple search query as below would give no results

For the query to give correct results it needs to be modifed as below