当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayObject::ksort方法代码示例

本文整理汇总了PHP中ArrayObject::ksort方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject::ksort方法的具体用法?PHP ArrayObject::ksort怎么用?PHP ArrayObject::ksort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayObject的用法示例。


在下文中一共展示了ArrayObject::ksort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: C

<?php

/* Prototype  : int ArrayObject::ksort()
 * Description: proto int ArrayIterator::ksort()
 * Sort the entries by key. 
 * Source code: ext/spl/spl_array.c
 * Alias to functions: 
 */
echo "*** Testing ArrayObject::ksort() : basic functionality ***\n";
class C
{
    public $x = 'prop1';
    public $z = 'prop2';
    public $a = 'prop3';
    private $b = 'prop4';
}
$c = new C();
$ao1 = new ArrayObject($c);
var_dump($ao1->ksort());
var_dump($ao1, $c);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:22,代码来源:arrayObject_ksort_basic2.php

示例2: getTableContent

function getTableContent($headers, $param)
{
    $paramArrayObject = new ArrayObject($param);
    $paramArrayObject->ksort();
    $o = "<table>";
    $o .= "<tr>";
    foreach ($headers as $header) {
        $o .= "<th>" . $header . "</th>";
    }
    $o .= "</tr>";
    if (is_array($param)) {
        foreach ($paramArrayObject as $key => $value) {
            $restrictedAvailability = false;
            $o .= '<tr class="linkable" id="' . $key . '">';
            $o .= "<td>" . $key;
            foreach ($value as $val => $value1) {
                if ($val == 'availability' && $value1 == 'kdp') {
                    $o .= '<br><span class="label label-warning">Legacy Only</span>';
                    $restrictedAvailability = true;
                }
            }
            //if (!$restrictedAvailability)
            //	$o.= '<br><span class="label label-success">Legacy / Universal</span>';
            $o .= "</td>";
            foreach ($value as $val => $value) {
                if ($val != 'availability' && $val != 'example') {
                    $o .= "<td>" . $value . "</td>";
                }
                if ($val == 'example') {
                    if ($value != '') {
                        $o .= '<td><a href="' . $value . '" target="_blank">Example</a></td>';
                    } else {
                        $o .= '<td>-</td>';
                    }
                }
            }
            /*
            				foreach( $value as $val){
            						$o.= "<td>".$val."</td>";
            				}
            				$o.= "</tr>";*/
        }
    }
    $o .= "</table>";
    return $o;
}
开发者ID:nmbolton,项目名称:mwEmbed,代码行数:46,代码来源:content_api.php

示例3: available

 /**
  * Return the list of available modules, including uninstalled modules
  *
  * @uses  Message::warn
  * @uses  HTML::anchor
  * @uses  Route::get
  * @uses  Route::uri
  */
 public static function available()
 {
     if (empty(self::$available)) {
         $upgrade = FALSE;
         $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
         $paths = (array) Config::get('site.module_paths', array(MODPATH));
         // Make sure MODPATH is set else add last
         if (!in_array(MODPATH, $paths)) {
             array_push($paths, MODPATH);
         }
         // Iterate over each config path
         foreach ($paths as $name => $path) {
             foreach (glob($path . "*/module.info") as $file) {
                 $name = basename(dirname($file));
                 $modules->{$name} = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
                 $m =& $modules->{$name};
                 $m->active = self::is_active($name);
                 $m->title = isset($m->title) ? (string) $m->title : $name;
                 $m->code_version = $m->version;
                 $m->version = self::get_version($name);
                 $m->locked = false;
                 $m->visible = isset($m->visible) ? (bool) $m->visible : true;
                 $m->author = isset($m->author) ? (string) $m->author : 'Gleez Team';
                 $m->authorURL = isset($m->authorURL) ? (string) $m->authorURL : 'http://gleezcms.org/';
                 $m->path = realpath(dirname($file)) . DS;
                 // Skip this module in list if the module is hidden
                 if ($m->visible === false && isset($modules[$name])) {
                     unset($modules[$name]);
                 }
                 // Check installed and available version and set message
                 if ($m->active and $m->version != $m->code_version) {
                     $upgrade = TRUE;
                 }
             }
         }
         if ($upgrade) {
             Message::warn(__('Some of your modules are out of date. :upgrade_url', array(':upgrade_url' => HTML::anchor(Route::get('admin/module')->uri(array('action' => 'upgrade')), __('Upgrade now!')))));
         }
         // Lock certain modules
         $modules->user->locked = TRUE;
         $modules->ksort();
         self::$available = $modules;
     }
     return self::$available;
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:53,代码来源:module.php

示例4: getFiles

 public function getFiles($return_as_array = false)
 {
     // compose the full name of the filter class
     $classname = 'Koch_' . $this->filtername . 'FilterIterator';
     // wrap the iterator in a filter class, when looking for a specific file type, like imagesOnly'
     $iterator = new $classname(new DirectoryIterator($this->getDirectory()));
     // return objects
     if ($return_as_array === false) {
         // create new array to take the SPL FileInfo Objects
         $data = new ArrayObject();
         // while iterating
         foreach ($iterator as $file) {
             /**
              * push the SPL FileInfo Objects into the array
              * @see http://www.php.net/~helly/php/ext/spl/classSplFileInfo.html
              */
             $data[$file->getFilename()] = $file->getFileInfo();
         }
         $data->ksort();
     } else {
         // return array
         // create array
         $data = array();
         // while iterating
         foreach ($iterator as $file) {
             $wwwpath = WWW_ROOT . DIRECTORY_SEPARATOR . $this->getDirectory() . DIRECTORY_SEPARATOR . $file->getFilename();
             $wwwpath = str_replace('//', '/', $wwwpath);
             $data[$wwwpath] = $file->getFilename();
         }
     }
     // return the array with SPL FileInfo Objects
     return $data;
 }
开发者ID:Clansuite,项目名称:Clansuite,代码行数:33,代码来源:File.php

示例5: available

 /**
  * Return the list of available modules, including uninstalled modules.
  */
 static function available()
 {
     if (empty(self::$available)) {
         $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
         foreach (glob(MODPATH . "*/module.info") as $file) {
             $module_name = basename(dirname($file));
             $modules->{$module_name} = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
             $m =& $modules->{$module_name};
             $m->installed = self::is_installed($module_name);
             $m->active = self::is_active($module_name);
             $m->code_version = $m->version;
             $m->version = self::get_version($module_name);
             $m->locked = false;
         }
         // Lock certain modules
         $modules->gallery->locked = true;
         $modules->user->locked = true;
         $modules->ksort();
         self::$available = $modules;
     }
     return self::$available;
 }
开发者ID:kstyrvoll,项目名称:gallery3,代码行数:25,代码来源:module.php

示例6: ArrayObject

<?php

/* Prototype  : int ArrayObject::ksort()
 * Description: proto int ArrayIterator::ksort()
 * Sort the entries by key. 
 * Source code: ext/spl/spl_array.c
 * Alias to functions: 
 */
echo "*** Testing ArrayObject::ksort() : basic functionality ***\n";
$ao1 = new ArrayObject(array(4, 2, 3));
$ao2 = new ArrayObject(array('b' => 4, 'a' => 2, 'q' => 3, 99 => 'x'));
var_dump($ao1->ksort());
var_dump($ao1);
var_dump($ao2->ksort('blah'));
var_dump($ao2);
var_dump($ao2->ksort(SORT_STRING));
var_dump($ao2);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:19,代码来源:arrayObject_ksort_basic1.php

示例7: array

) */


/*
ksort($aa);
print_r($aa);
*/
/*
asort($aa);
print_r($aa);*/
?>

<?php
$name = array("d" => "Mark", "a" => "David", "b" => "Peter", "c" => "Martha");
$nameArrayObject = new ArrayObject($name);
$nameArrayObject->ksort();
 
foreach ($nameArrayObject as $key => $val) {
    echo "$key = $val\n";
}
 ?>

<?php
    $foofa = function ($x){
        return $x*$x;
    };
    
    $foo = create_function('$x', 'return $x*$x;');
    $bar = create_function("\$x", "return \$x*\$x;");
    echo $foo(10) . PHP_EOL;
    echo $bar(5). PHP_EOL;
开发者ID:jestintab,项目名称:zendphp,代码行数:31,代码来源:test-func-array-mics-1.php

示例8: array

<?php

$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
$fruitArrayObject = new ArrayObject($fruits);
$fruitArrayObject->ksort();
foreach ($fruitArrayObject as $key => $val) {
    echo "{$key} = {$val}\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:8,代码来源:ksort.php

示例9: available

 /**
  * Return the list of available modules, including uninstalled modules.
  */
 static function available()
 {
     if (empty(self::$available)) {
         $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
         foreach (glob(MODPATH . "*/module.info") as $file) {
             $module_name = basename(dirname($file));
             $modules->{$module_name} = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
             $m =& $modules->{$module_name};
             $m->installed = module::is_installed($module_name);
             $m->active = module::is_active($module_name);
             $m->code_version = $m->version;
             $m->version = module::get_version($module_name);
             $m->locked = false;
             if ($m->active && $m->version != $m->code_version) {
                 site_status::warning(t("Some of your modules are out of date.  <a href=\"%upgrader_url\">Upgrade now!</a>", array("upgrader_url" => url::site("upgrader"))), "upgrade_now");
             }
         }
         // Lock certain modules
         $modules->gallery->locked = true;
         $identity_module = module::get_var("gallery", "identity_provider", "user");
         $modules->{$identity_module}->locked = true;
         $modules->ksort();
         self::$available = $modules;
     }
     return self::$available;
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:29,代码来源:module.php

示例10: applyPermissions

 /**
  * @param \ArrayObject $project The project
  */
 public function applyPermissions(\ArrayObject $project)
 {
     if ($this->app["config"]["develmode"] || !$this->processProvider->commandExists("setfacl")) {
         if (!file_exists($this->fileSystemProvider->getProjectDirectory($project["name"]))) {
             $this->dialogProvider->logNotice($this->fileSystemProvider->getProjectDirectory($project["name"]) . " does not exist, do not chmod");
         } else {
             $this->processProvider->executeSudoCommand('chmod -R 777 ' . $this->fileSystemProvider->getProjectDirectory($project["name"]));
         }
         if (!file_exists($this->fileSystemProvider->getProjectDirectory($project["name"]) . '/.ssh/')) {
             $this->dialogProvider->logNotice($this->fileSystemProvider->getProjectDirectory($project["name"]) . '/.ssh/' . " does not exist, do not chmod");
         } else {
             $this->processProvider->executeSudoCommand('chmod -R 700 ' . $this->fileSystemProvider->getProjectDirectory($project["name"]) . '/.ssh/');
         }
     } else {
         $permissions_sorted = new \ArrayObject($project["permissions"]);
         $permissions_sorted->ksort();
         /** @var PermissionDefinition $pd */
         foreach ($permissions_sorted as $pd) {
             $path = $this->fileSystemProvider->getProjectDirectory($project["name"]) . $pd->getPath();
             foreach ($pd->getAcl() as $acl) {
                 if (file_exists($path)) {
                     $this->processProvider->executeSudoCommand('setfacl ' . $this->projectConfigProvider->searchReplacer($acl, $project) . ' ' . $path, true);
                 } else {
                     $this->dialogProvider->logNotice($path . " does not exist, do not chmod");
                 }
             }
         }
     }
     $this->processProvider->executeSudoCommand('find ' . $this->fileSystemProvider->getProjectDirectory($project["name"]) . '/ -type d -exec chmod o+rx {} \\;');
 }
开发者ID:kunstmaan,项目名称:skylab,代码行数:33,代码来源:PermissionsProvider.php

示例11: ArrayObject

<?php

// SPL stands for Standard PHP Library
$fruits = ["dollar" => 10, "sterlin" => 5, "euro" => 25];
$obj = new ArrayObject($fruits);
foreach ($obj as $key => $value) {
    echo "{$key} ... {$value}" . PHP_EOL;
}
$obj->asort();
foreach ($obj as $key => $value) {
    echo "{$key} ... {$value}" . PHP_EOL;
}
$obj->ksort();
foreach ($obj as $key => $value) {
    echo "{$key} ... {$value}" . PHP_EOL;
}
/*
Flag Effect

ArrayObject::STD_PROP_LIST  Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.).
ArrayObject::ARRAY_AS_PROPS Entries can be accessed as properties (read and write).
*/
var_dump($obj->dollar);
$obj->setFlags(ArrayObject::ARRAY_AS_PROPS);
var_dump($obj->dollar);
foreach ($obj as $key => $value) {
    echo "{$key} => {$value}" . PHP_EOL;
}
开发者ID:wilk,项目名称:zend-php-certification,代码行数:28,代码来源:spl.php

示例12: ksort

 /**
  * Provide PHP5.1 compat for object ksort()
  * 
  * @return object
  */
 public function ksort()
 {
     if (method_exists('ArrayObject', 'ksort')) {
         parent::ksort();
     } else {
         $tmp = $this->getArrayCopy();
         ksort($tmp);
         $this->exchangeArray($tmp);
     }
     return $this;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:16,代码来源:Abstract.php

示例13: ksort

 /**
  * ksort
  *
  * @return BEAR_Ro
  * @ignore
  */
 public function ksort()
 {
     parent::ksort();
     return $this;
 }
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:11,代码来源:Ro.php

示例14: ksort

 public function ksort()
 {
     $this->lazyLoadArray();
     parent::ksort();
 }
开发者ID:jinshana,项目名称:kajonacms,代码行数:5,代码来源:class_orm_assignment_array.php

示例15: available

 /**
  * Return the list of available modules.
  */
 static function available()
 {
     $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
     foreach (array_merge(array("core/module.info"), glob(MODPATH . "*/module.info")) as $file) {
         $module_name = basename(dirname($file));
         $modules->{$module_name} = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
         $modules->{$module_name}->installed = empty(self::$modules[$module_name]) ? null : self::$modules[$module_name]->version;
         $modules->{$module_name}->locked = false;
     }
     // Lock certain modules
     $modules->core->locked = true;
     $modules->user->locked = true;
     $modules->ksort();
     return $modules;
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:18,代码来源:module.php


注:本文中的ArrayObject::ksort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。