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


PHP convert_to_array函数代码示例

本文整理汇总了PHP中convert_to_array函数的典型用法代码示例。如果您正苦于以下问题:PHP convert_to_array函数的具体用法?PHP convert_to_array怎么用?PHP convert_to_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __construct

 public function __construct($request, $response)
 {
     $this->request = $request;
     $this->response = $response;
     $db = new MongoDAO($this->request->endpoint);
     $db = $db->c;
     $result = $db->find();
     $this->response = convert_to_array($result);
 }
开发者ID:xe4me,项目名称:php-restful-api-,代码行数:9,代码来源:CatsGetAll.php

示例2: __construct

 public function __construct($request, $response)
 {
     //sleep(2);
     $this->request = $request;
     $this->response = $response;
     $start = (int) $this->request->input->start;
     $last = $this->request->input->last;
     $db = new MongoDAO($this->request->endpoint);
     $db = $db->c;
     $result = $db->find(array(AdKeys::PUBLISH_TIME => array('$gte' => $last)))->limit(20)->sort(array(AdKeys::MID => -1));
     $this->response = convert_to_array($result);
 }
开发者ID:xe4me,项目名称:php-restful-api-,代码行数:12,代码来源:AddsGetNew.php

示例3: get

 /**
 	* Method : userInfo
 	* Will get user infrmation from database by `id`
 */
 public function get()
 {
     $db = new MongoDAO($this->request->endpoint);
     $db = $db->c;
     // if there is an id specified , just search for that id and return the result
     if ($this->request->id != "") {
         $result = $db->findOne(array('_id' => new MongoId($this->request->id)));
         return $result;
     } else {
         $result = $db->find();
         $result = convert_to_array($result);
         return $result;
     }
 }
开发者ID:xe4me,项目名称:php-restful-api-,代码行数:18,代码来源:Cats.php

示例4: object_init

 /**
  * Returns JavaScript code to initialise a new object
  *
  * @param string $var If it is null then no var is assigned the new object.
  * @param string $class The class to initialise an object for.
  * @param array $arguments An array of args to pass to the init method.
  * @param array $requirements Any modules required for this class.
  * @param int $delay The delay before initialisation. 0 = no delay.
  * @return string Some JS code
  */
 public static function object_init($var, $class, array $arguments = null, array $requirements = null, $delay = 0)
 {
     if (is_array($arguments)) {
         $arguments = array_map('json_encode', convert_to_array($arguments));
         $arguments = implode(', ', $arguments);
     }
     if ($var === null) {
         $js = "new {$class}(Y, {$arguments});";
     } else {
         if (strpos($var, '.') !== false) {
             $js = "{$var} = new {$class}(Y, {$arguments});";
         } else {
             $js = "var {$var} = new {$class}(Y, {$arguments});";
         }
     }
     if ($delay) {
         $delay = $delay * 1000;
         // in miliseconds
         $js = "setTimeout(function() { {$js} }, {$delay});";
     }
     if (count($requirements) > 0) {
         $requirements = implode("', '", $requirements);
         $js = "Y.use('{$requirements}', function(Y){ {$js} });";
     }
     return $js . "\n";
 }
开发者ID:jtibbetts,项目名称:moodle,代码行数:36,代码来源:outputcomponents.php

示例5: optional_param

// course_sections.id
$sectionreturn = optional_param('sr', 0, PARAM_INT);
$PAGE->set_url('/course/editsection.php', array('id' => $id, 'sr' => $sectionreturn));
$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
$sectionnum = $section->section;
require_login($course);
$context = context_course::instance($course->id);
require_capability('moodle/course:update', $context);
// Get section_info object with all availability options.
$sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
$editoroptions = array('context' => $context, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$mform = course_get_format($course->id)->editsection_form($PAGE->url, array('cs' => $sectioninfo, 'editoroptions' => $editoroptions));
// set current value, make an editable copy of section_info object
// this will retrieve all format-specific options as well
$mform->set_data(convert_to_array($sectioninfo));
if ($mform->is_cancelled()) {
    // Form cancelled, return to course.
    redirect(course_get_url($course, $section, array('sr' => $sectionreturn)));
} else {
    if ($data = $mform->get_data()) {
        // Data submitted and validated, update and return to course.
        $DB->update_record('course_sections', $data);
        rebuild_course_cache($course->id, true);
        if (isset($data->section)) {
            // Usually edit form does not change relative section number but just in case.
            $sectionnum = $data->section;
        }
        if (!empty($CFG->enableavailability)) {
            // Update grade and completion conditions.
            $sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
开发者ID:helenagarcia90,项目名称:moodle,代码行数:31,代码来源:editsection.php

示例6: test_convert_to_array

 /**
  * Test function convert_to_array()
  */
 public function test_convert_to_array()
 {
     // Check that normal classes are converted to arrays the same way as (array) would do.
     $obj = new stdClass();
     $obj->prop1 = 'hello';
     $obj->prop2 = array('first', 'second', 13);
     $obj->prop3 = 15;
     $this->assertEquals(convert_to_array($obj), (array) $obj);
     // Check that context object (with iterator) is converted to array properly.
     $obj = context_system::instance();
     $ar = array('id' => $obj->id, 'contextlevel' => $obj->contextlevel, 'instanceid' => $obj->instanceid, 'path' => $obj->path, 'depth' => $obj->depth);
     $this->assertEquals(convert_to_array($obj), $ar);
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:16,代码来源:moodlelib_test.php

示例7: yui_module

 /**
  * Creates a JavaScript function call that requires one or more modules to be loaded.
  *
  * This function can be used to include all of the standard YUI module types within JavaScript:
  *     - YUI3 modules    [node, event, io]
  *     - YUI2 modules    [yui2-*]
  *     - Moodle modules  [moodle-*]
  *     - Gallery modules [gallery-*]
  *
  * @param array|string $modules One or more modules
  * @param string $function The function to call once modules have been loaded
  * @param array $arguments An array of arguments to pass to the function
  * @param string $galleryversion The gallery version to use
  * @param bool $ondomready
  */
 public function yui_module($modules, $function, array $arguments = null, $galleryversion = null, $ondomready = false)
 {
     global $CFG;
     if (!$galleryversion) {
         $galleryversion = '2010.04.08-12-35';
     }
     if (!is_array($modules)) {
         $modules = array($modules);
     }
     if (empty($CFG->useexternalyui)) {
         // We need to set the M.yui.galleryversion to the correct version
         $jscode = 'M.yui.galleryversion=' . json_encode($galleryversion) . ';';
     } else {
         // Set Y's config.gallery to the version
         $jscode = 'Y.config.gallery=' . json_encode($galleryversion) . ';';
     }
     $jscode .= 'Y.use(' . join(',', array_map('json_encode', convert_to_array($modules))) . ',function() {' . js_writer::function_call($function, $arguments) . '});';
     if ($ondomready) {
         $jscode = "Y.on('domready', function() { {$jscode} });";
     }
     $this->jsinitcode[] = $jscode;
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:37,代码来源:outputrequirementslib.php

示例8: get_db_record

 /**
  * Returns the complete corresponding record from DB table course_categories
  *
  * Mostly used in deprecated functions
  *
  * @return stdClass
  */
 public function get_db_record()
 {
     global $DB;
     if ($record = $DB->get_record('course_categories', array('id' => $this->id))) {
         return $record;
     } else {
         return (object) convert_to_array($this);
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:coursecatlib.php

示例9: get_course_display_name_for_list

/**
 * Gets the name of a course to be displayed when showing a list of courses.
 * By default this is just $course->fullname but user can configure it. The
 * result of this function should be passed through print_string.
 * @param stdClass|course_in_list $course Moodle course object
 * @return string Display name of course (either fullname or short + fullname)
 */
function get_course_display_name_for_list($course)
{
    global $CFG;
    if (!empty($CFG->courselistshortnames)) {
        if (!$course instanceof stdClass) {
            $course = (object) convert_to_array($course);
        }
        return get_string('courseextendednamedisplay', '', $course);
    } else {
        return $course->fullname;
    }
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:19,代码来源:moodlelib.php

示例10: yui_module

 /**
  * Creates a JavaScript function call that requires one or more modules to be loaded.
  *
  * This function can be used to include all of the standard YUI module types within JavaScript:
  *     - YUI3 modules    [node, event, io]
  *     - YUI2 modules    [yui2-*]
  *     - Moodle modules  [moodle-*]
  *     - Gallery modules [gallery-*]
  *
  * Before writing new code that makes extensive use of YUI, you should consider it's replacement AMD/JQuery.
  * @see js_call_amd()
  *
  * @param array|string $modules One or more modules
  * @param string $function The function to call once modules have been loaded
  * @param array $arguments An array of arguments to pass to the function
  * @param string $galleryversion Deprecated: The gallery version to use
  * @param bool $ondomready
  */
 public function yui_module($modules, $function, array $arguments = null, $galleryversion = null, $ondomready = false)
 {
     if (!is_array($modules)) {
         $modules = array($modules);
     }
     if ($galleryversion != null) {
         debugging('The galleryversion parameter to yui_module has been deprecated since Moodle 2.3.');
     }
     $jscode = 'Y.use(' . join(',', array_map('json_encode', convert_to_array($modules))) . ',function() {' . js_writer::function_call($function, $arguments) . '});';
     if ($ondomready) {
         $jscode = "Y.on('domready', function() { {$jscode} });";
     }
     $this->jsinitcode[] = $jscode;
 }
开发者ID:rsturley,项目名称:moodle,代码行数:32,代码来源:outputrequirementslib.php

示例11: optional_param

// course_sections.id
$sectionreturn = optional_param('sr', 0, PARAM_INT);
$PAGE->set_url('/course/editsection.php', array('id' => $id, 'sr' => $sectionreturn));
$section = $DB->get_record('course_sections', array('id' => $id), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $section->course), '*', MUST_EXIST);
$sectionnum = $section->section;
require_login($course);
$context = context_course::instance($course->id);
require_capability('moodle/course:update', $context);
// Get section_info object with all availability options.
$sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
$editoroptions = array('context' => $context, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true);
$mform = course_get_format($course->id)->editsection_form($PAGE->url, array('cs' => $sectioninfo, 'editoroptions' => $editoroptions));
// set current value, make an editable copy of section_info object
// this will retrieve all format-specific options as well
$initialdata = convert_to_array($sectioninfo);
if (!empty($CFG->enableavailability)) {
    $initialdata['availabilityconditionsjson'] = $sectioninfo->availability;
}
$mform->set_data($initialdata);
if ($mform->is_cancelled()) {
    // Form cancelled, return to course.
    redirect(course_get_url($course, $section, array('sr' => $sectionreturn)));
} else {
    if ($data = $mform->get_data()) {
        // Data submitted and validated, update and return to course.
        // For consistency, we set the availability field to 'null' if it is empty.
        if (!empty($CFG->enableavailability)) {
            // Renamed field.
            $data->availability = $data->availabilityconditionsjson;
            unset($data->availabilityconditionsjson);
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:editsection.php

示例12: convert_to_array

/**
 * Converts an object into an associative array
 *
 * This function converts an object into an associative array by iterating
 * over its public properties. Because this function uses the foreach
 * construct, Iterators are respected. It works recursively on arrays of objects.
 * Arrays and simple values are returned as is.
 *
 * If class has magic properties, it can implement IteratorAggregate
 * and return all available properties in getIterator()
 *
 * @param mixed $var
 * @return array
 */
function convert_to_array($var)
{
    $result = array();
    $references = array();
    // loop over elements/properties
    foreach ($var as $key => $value) {
        // recursively convert objects
        if (is_object($value) || is_array($value)) {
            // but prevent cycles
            if (!in_array($value, $references)) {
                $result[$key] = convert_to_array($value);
                $references[] = $value;
            }
        } else {
            // simple values are untouched
            $result[$key] = $value;
        }
    }
    return $result;
}
开发者ID:nmicha,项目名称:moodle,代码行数:34,代码来源:moodlelib.php

示例13: generateSelectUI

function generateSelectUI($context, $objects, $title, $id, $field, $selected, $extra)
{
    $ci =& get_instance();
    $ci->load->helper('form');
    return form_dropdown($title, convert_to_array($objects, $id, $field), $selected, $extra);
}
开发者ID:acelumaad,项目名称:leave-system,代码行数:6,代码来源:ui_helper.php

示例14: convert_to_array

function convert_to_array($xml)
{
    if (is_string($xml)) {
        $xml = new SimpleXMLElement($xml);
    }
    $children = $xml->children();
    if (!$children) {
        return (string) $xml;
    }
    $arr = array();
    foreach ($children as $key => $node) {
        $node = convert_to_array($node);
        // support for 'anon' non-associative arrays
        if ($key == 'anon') {
            $key = count($arr);
        }
        // if the node is already set, put it into an array
        if (isset($arr[$key])) {
            if (!is_array($arr[$key]) || !isset($arr[$key][0]) || $arr[$key][0] == null) {
                $arr[$key] = array($arr[$key]);
            }
            $arr[$key][] = $node;
        } else {
            $arr[$key] = $node;
        }
    }
    return $arr;
}
开发者ID:carriercomm,项目名称:opengateway,代码行数:28,代码来源:check_coupon.php

示例15: convert_to_array

">
            <?php 
            }
            ?>
    <?php 
            echo $description;
            ?>
</div>
				<?php 
        }
        if (riake('type', $item) == "buttons") {
            $value = convert_to_array(riake('value', $item));
            $buttons_types = convert_to_array(riake('buttons_types', $item, 'submit'));
            $name = convert_to_array(riake('name', $item));
            $classes = convert_to_array(riake('classes', $item, 'btn-primary'));
            $attrs_string = convert_to_array(riake('attrs_string', $item, ''));
            ?>
<div class="form-group">
	<div class="input-group">
    	<?php 
            foreach ($value as $_key => $_button) {
                ?>
	  <input class="btn btn-sm <?php 
                echo riake($_key, $classes, 'btn-primary');
                ?>
" <?php 
                echo riake($_key, $attrs_string);
                ?>
 type="<?php 
                echo riake($_key, $buttons_types, 'submit');
                ?>
开发者ID:eboominathan,项目名称:tendoo-cms,代码行数:31,代码来源:gui_items+-+Deprecated.php


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