當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JInput::getArray方法代碼示例

本文整理匯總了PHP中JInput::getArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP JInput::getArray方法的具體用法?PHP JInput::getArray怎麽用?PHP JInput::getArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JInput的用法示例。


在下文中一共展示了JInput::getArray方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetArrayNested

 /**
  * Test the JInput::get method using a nested data set.
  */
 public function testGetArrayNested()
 {
     $filterMock = new JFilterInputMockTracker();
     $input = new JInput(array('var2' => 34, 'var3' => array('var2' => 'test'), 'var4' => array('var1' => array('var2' => 'test'))), array('filter' => $filterMock));
     $this->assertThat($input->getArray(array('var2' => 'filter2', 'var3' => array('var2' => 'filter3'))), $this->equalTo(array('var2' => 34, 'var3' => array('var2' => 'test'))), 'Line: ' . __LINE__ . '.');
     $this->assertThat($input->getArray(array('var4' => array('var1' => array('var2' => 'filter1')))), $this->equalTo(array('var4' => array('var1' => array('var2' => 'test')))), 'Line: ' . __LINE__ . '.');
     $this->assertThat($filterMock->calls['clean'][0], $this->equalTo(array(34, 'filter2')), 'Line: ' . __LINE__ . '.');
     $this->assertThat($filterMock->calls['clean'][1], $this->equalTo(array(array('var2' => 'test'), 'array')), 'Line: ' . __LINE__ . '.');
 }
開發者ID:raquelsa,項目名稱:Joomla,代碼行數:12,代碼來源:JInputTest.php

示例2: testGetArrayWithoutSpecifiedVariables

 /**
  * Test the JInput::getArray method without specified variables.
  *
  * @return  void
  *
  * @since   12.3
  */
 public function testGetArrayWithoutSpecifiedVariables()
 {
     $array = array('var2' => 34, 'var3' => array('var2' => 'test'), 'var4' => array('var1' => array('var2' => 'test')), 'var5' => array('foo' => array()), 'var6' => array('bar' => null), 'var7' => null);
     $input = new JInput($array);
     $this->assertEquals($input->getArray(), $array);
 }
開發者ID:joomla-projects,項目名稱:media-manager-improvement,代碼行數:13,代碼來源:JInputTest.php

示例3: getPostedData

 /**
  * Returns posted data in array format
  *
  * @return  array
  *
  * @since   1.2
  */
 public static function getPostedData()
 {
     $input = JFactory::getApplication()->input;
     $inputData = file_get_contents("php://input");
     if (is_object($inputData)) {
         $inputData = JArrayHelper::fromObject($inputData);
     } elseif (is_string($inputData)) {
         $inputData = trim($inputData);
         $parsedData = null;
         // We try to transform it into JSON
         if ($data_json = @json_decode($inputData, true)) {
             if (json_last_error() == JSON_ERROR_NONE) {
                 $parsedData = (array) $data_json;
             }
         }
         // We try to transform it into XML
         if (is_null($parsedData) && ($xml = @simplexml_load_string($inputData))) {
             $json = json_encode((array) $xml);
             $parsedData = json_decode($json, true);
         }
         // We try to transform it into Array
         if (is_null($parsedData) && !empty($inputData) && !is_array($inputData)) {
             parse_str($inputData, $parsedData);
         }
         $inputData = $parsedData;
     } else {
         $inputData = $input->post->getArray();
     }
     // Filter data with JInput default filter
     $postedData = new JInput($inputData);
     return $postedData->getArray();
 }
開發者ID:thangredweb,項目名稱:redCORE,代碼行數:39,代碼來源:api.php


注:本文中的JInput::getArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。