My Linux Guide
  • Home
Sign in Subscribe

PHP

A collection of 2 posts
PHP

PHP function to remove whitespaces from a string

Usage : $spaceRemovedString = removeWhiteSpaces($stringWithSpace);   Function : function removeWhiteSpaces($spaceStr) { $newStr = preg_replace('/\s+/', '', $spaceStr); return $newStr; }
Dec 28, 2012
PHP

Function to write a message to a text file

Sometimes , we need to write some logging information to a text file in php. The following function takes  filename and message as the parameter and logs whatever you pass to the file with date and time. function logToFile($fileName, $logMessage) {     $logDirectory = “/path/to/log/dir”;          $fileHandler = fopen($logDir . '/'
Nov 17, 2012
Page 1 of 1
My Linux Guide © 2025
Powered by Ghost