Detailed Guide On Arrays In PHP
Here is an link from digg.com, detailed guide on arrays in php Detailed Guide On Arrays In PHP
Here is an link from digg.com, detailed guide on arrays in php Detailed Guide On Arrays In PHP
Consider the file “list.txt” below containing two columns parent id and child id separated by “space” on each row That is the source for data for computation: list.txt 0 1 1 2 2 3 0 4 4 5 0 6 6 7 Below is the script for getting an array of the hierachical node tree tree.php <? $l = file(”./list.txt”);
$list = array();
for ($i = 0;$i < count($l); [...]
* .at matches any three-character string ending with “at”, including “hat”, “cat”, and “bat”. * [hc]at matches “hat” and “cat”. * [^b]at matches all strings matched by .at except “bat”. * ^[hc]at matches “hat” and “cat”, but only at the beginning [...]
In the example below dbop is an test class: class dbop { $aUpdateData=Array(); public function createOnDupUpdateString($val,$key){ $this->aUpdateData[$key]=$val; } public function insertOrUpdOndupKey($aUpdate) { array_walk($aUpdate, array($this, ‘createOnDupUpdateString’)); // create new array. } } In the function “insertOrUpdOndupKey” for each element of array update function “createOnDupUpdateString” is applied using “array_walk”. For the function array_walk, pass the source array ($aUpdate) as first parameter and pass array of class object “$this” and name [...]
$aDir = glob(”/clt20/uploads/videos/*.flv”); The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.
memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.memcached drop the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.For more details [...]
/** *cURL class * This is a wrapper class for curl * $c = new curl; * // enable cache * $c = new curl(array(’cache’=>true)); * // enable cookie * $c = new curl(array(’cookie’=>true)); * // enable proxy * $c = new curl(array(’proxy’=>true)); * * // HTTP GET Method * $html = $c->get(’http://example.com’); * // [...]
/** * sendDataOnSocket * function to submit data via socket * @param string $sContent content to send * @param string $sHost Host name * @param string $sFilePath file to post data * @param string $sMethod method name * @return string aig response * @access public */ public static function sendDataOnSocket($sContent,$sHost,$sFilePath,$sMethod) { if(strlen($sHost)==0) { return array(1, "Empty Host name"); }else if (strlen($sMethod)==0) { return array(1, "Empty Method"); } $fp = fsockopen($sHost, "80", [...]
/** * validateXmlAgainstXsd * function to validate xml against xsd file provided * @param string $error error * @return string api response * @access public */ public static function validateXmlAgainstXsd($sXmlPath,$sXsdPath) { // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument(); $xml->load($sXmlPath); if (!$xml->schemaValidate($sXsdPath)) { $aError =self::libxml_display_errors(); $iError=1; } else { $iError=0; } return array($iError,$aError); } Example of XSD file: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:documentation xml:lang="en"> Job specification schema for scheduler.vubites.com Copyright 2010 satishgaudo.com. All rights reserved. </xs:documentation> </xs:annotation> <xs:element name="response" type="responseType"/> <xs:complexType name="responseType"> <xs:sequence> <xs:element name="status" [...]
/** * getFileMimeType * returns the mime type of the file * @param string $sFilePath File path * @return string mime type of the file * @access public */ public function getFileMimeType($sFilePath) { exec(’/usr/bin/file -i -b ‘ . realpath($sFilePath), $aOutput); $sType = $aOutput[0]; $aMimeTypeDet = explode(’;', $sType); return trim($aMimeTypeDet[0]); }