note 94952 deleted from function.file-put-contents by danbrown

From: Date: Fri, 04 Dec 2009 14:56:58 +0000
Subject: note 94952 deleted from function.file-put-contents by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163574@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- Create dir path if trying to write to a directory that does not exist yet function forceContent($filePath, $content, $dirMode = 0777) { // Get path information $pathInfo = pathinfo($filePath); // Check if path exists if(!file_exists($pathInfo['dirname'])) { $result = mkdir($pathInfo['dirname'], 0777, true); if($result == false) { return false; } } // Create file return file_put_contents($filePath, $content); }

« previous php.notes (#163574) next »