function InflateArray($Data)
 {
     $Result = array();
     foreach ($Data as $Key => $Value) {
         if (strpos($Key, '.') !== FALSE) {
             $Keys = explode('.', $Key);
             $Collection =& $Result;
             foreach ($Keys as $SubKey) {
                 if (!isset($Collection[$SubKey])) {
                     $Collection[$SubKey] = array();
                 }
                 $Collection =& $Collection[$SubKey];
             }
             if (count($Collection) == 0) {
                 $Collection = $Value;
             } else {
                 mergeArrays($Collection, $Value);
             }
         } else {
             $Collection =& $Result[$Key];
             if ($Collection === NULL) {
                 $Collection = array();
             }
             $Collection = mergeArrays($Value, $Collection);
         }
     }
     return $Result;
 }
 /**
  * Update cart function
  * read the content of cart and update it with the value set in the update form
  */
 public function update()
 {
     if ($this->request->is('post')) {
         if (!empty($this->request->data)) {
             $items = $this->Cart->readItem();
             $item_id = $this->request->data['Cart']['item_id'];
             $item_size = $this->request->data['Cart']['item_size'];
             $count = $this->request->data['Cart']['count'];
             function mergeArrays($item_id, $item_size, $count)
             {
                 $result = array();
                 foreach ($item_id as $key => $name) {
                     $result[$name] = array($item_size[$key] => $count[$key]);
                 }
                 return $result;
             }
         }
         CakeSession::write('cart', mergeArrays($item_id, $item_size, $count));
         $this->redirect(array('action' => 'view'));
     }
 }
 /**
  * Takes a set of form data ($Form->_PostValues), validates them, and
  * inserts or updates them to the configuration file.
  *
  * @param array $FormPostValues An associative array of $Field => $Value pairs that represent data posted
  * from the form in the $_POST or $_GET collection.
  */
 public function save($FormPostValues, $Live = false)
 {
     // Fudge your way through the schema application. This will allow me to
     // force the validation object to expect the fieldnames contained in
     // $this->Data.
     $this->Validation->setSchema($this->Data);
     // Validate the form posted values
     if ($this->Validation->validate($FormPostValues)) {
         // Merge the validation fields and the forced settings into a single array
         $Settings = $this->Validation->validationFields();
         if (is_array($this->_ForceSettings)) {
             $Settings = mergeArrays($Settings, $this->_ForceSettings);
         }
         $SaveResults = saveToConfig($Settings);
         // If the Live flag is true, set these in memory too
         if ($SaveResults && $Live) {
             Gdn::config()->set($Settings, true);
         }
         return $SaveResults;
     } else {
         return false;
     }
 }
function getPagesEpisodes($url, $content)
{
    $episodesRecovered = array();
    //Get number of episodes pages
    preg_match("/<i>\\((.*) pages\\)/siU", $content, $episodeNumber);
    $episodeNumber = $episodeNumber[1];
    //Get all episodes
    preg_match_all("/<div class=\"episode\"><a href=\"(.*)\"><b>(.*)</siU", $content, $episodes, PREG_SET_ORDER);
    $episodesRecovered = mergeArrays($episodesRecovered, $episodes);
    for ($i = 2; $i <= $episodeNumber; ++$i) {
        $content = file_get_contents($url . "&page=" . $i);
        preg_match_all("/<div class=\"episode\"><a href=\"(.*)\"><b>(.*)</siU", $content, $episodes, PREG_SET_ORDER);
        $episodesRecovered = mergeArrays($episodesRecovered, $episodes);
        if ($i > 20) {
            return;
        }
    }
    return $episodesRecovered;
}