DreamsCoder.com

We Code your Dreams
home > php programs

How to Integrate Google reCAPTCHA in Your Website





How to Integrate Google reCAPTCHA in Your Website

Label - php





XML to JSON conversion using PHP





XML to JSON conversion using PHP

$xmlNode = simplexml_load_file($url);
$arrayData = xmlToArray($xmlNode);
function xmlToArray($xml, $options = array()) 
{
   $defaults = array('namespaceSeparator' =>':',
//Seperator
 'attributePrefix' => '@',   
//to distinguish between attributes and nodes 
with the same name
 'alwaysArray' => array(),
 'autoArray' => true,        
 'textContent' => '$',       
 'autoText' => true,
 'keySearch' => false,       
 'keyReplace' => false       
    );
    $options = array_merge($defaults, $options);
    $namespaces = $xml->getDocNamespaces();
    $namespaces[''] = null; 
 
    //get attributes from all namespaces
    $attributesArray = array();
    foreach ($namespaces as $prefix => $namespace) 
      {
        foreach ($xml->attributes($namespace) as
 $attributeName => $attribute) {
            //replace characters in attribute name
            if ($options['keySearch']) $attributeName =
            str_replace($options['keySearch'],
 $options['keyReplace'], $attributeName);
            $attributeKey = $options['attributePrefix']. 
($prefix ? $prefix . 
$options['namespaceSeparator'] : '').$attributeName;
echo "
"; $attributesArray[$attributeKey] = (string)$attribute; } } $tagsArray = array(); foreach ($namespaces as $prefix => $namespace) { foreach ($xml->children($namespace) as $childXml) { $childArray = xmlToArray($childXml, $options); list($childTagName, $childProperties) = each($childArray); if ($options['keySearch']) $childTagName = str_replace($options['keySearch'], $options['keyReplace'], $childTagName); if ($prefix) $childTagName = $prefix . $options['namespaceSeparator'] . $childTagName; if (!isset($tagsArray[$childTagName])) { $tagsArray[$childTagName] = in_array($childTagName, $options['alwaysArray']) || !$options['autoArray'] ? array($childProperties) : $childProperties; } elseif (is_array($tagsArray[$childTagName]) && array_keys($tagsArray[$childTagName]) === range(0, count($tagsArray[$childTagName]) - 1)) { $tagsArray[$childTagName][] = $childProperties; } else { $tagsArray[$childTagName] = array($tagsArray[$childTagName], $childProperties); } } } //get text content of node $textContentArray = array(); $plainText = trim((string)$xml); if ($plainText !== '') $textContentArray[$options['textContent']] = $plainText; //stick it all together $propertiesArray = !$options['autoText'] || $attributesArray || $tagsArray || ($plainText === '')? array_merge($attributesArray, $tagsArray, $textContentArray) : $plainText; //return node as array return array( $xml->getName() => $propertiesArray ); } $jdata = json_encode($arrayData);

Label - php





Get distance between two cities using PHP





Get distance between two cities using PHP

Label - php





How to plot route between two points on google map using PHP





How to plot route between two points on google map using PHP

Label - php





Tracking visitors location





Tracking visitors location


Label - php





next page >






Privacy Policy
Copyright © 2018 by DreamsCoder. All Rights Reserved.
DreamsCoder Google Plus DreamsCoder Facebook



Latest Technology,Tricks and Tips