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


PHP SplFixedArray::toArray方法代码示例

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


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

示例1: bytestring

 public function bytestring($data)
 {
     $a = new \SplFixedArray(strlen($data));
     for ($i = 0; $i < strlen($data); $i++) {
         $a[$i] = str_pad(ord($data[$i]), 3, ' ', STR_PAD_LEFT);
     }
     return implode(' ', $a->toArray());
 }
开发者ID:chuyskywalker,项目名称:phpaes,代码行数:8,代码来源:Util.php

示例2: addRow

 /**
  * @param mix $row
  *
  * @return bool
  *
  * @throws \Exception
  * @throws \Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException
  */
 private function addRow(&$row)
 {
     $countColumns = count($this->columns);
     $tempRow = new \SplFixedArray($countColumns);
     for ($i = 0; $i < $countColumns; $i++) {
         try {
             $value = $this->propertyAccessor->getValue($row, $this->columns[$i]);
         } catch (UnexpectedTypeException $exception) {
             if (true === $this->getAllowNull()) {
                 $value = $this->getNullReplace();
             } else {
                 throw $exception;
             }
         }
         $tempRow[$i] = $this->escape($value, $this->columns[$i]);
     }
     switch ($this->getFormat()) {
         case 'csv':
             $this->data[] = implode($this->getSeparator(), $tempRow->toArray());
             break;
         case 'json':
             $this->data[] = array_combine($this->data[0], $tempRow->toArray());
             break;
         case 'pdf':
         case 'listData':
         case 'render':
             $this->data[] = $tempRow->toArray();
             break;
         case 'xls':
         case 'html':
             $this->data .= '<tr>';
             foreach ($tempRow as $val) {
                 $this->data .= '<td>' . $val . '</td>';
             }
             $this->data .= '</tr>';
             break;
         case 'xml':
             $this->data .= '<row>';
             $index = 0;
             foreach ($tempRow as $val) {
                 $this->data .= '<column name="' . $this->columns[$index] . '">' . $val . '</column>';
                 $index++;
             }
             $this->data .= '</row>';
             break;
     }
     return true;
 }
开发者ID:antqa,项目名称:DataExporterBundle,代码行数:56,代码来源:DataExporter.php

示例3: toArray

 /**
  * Returns a native array representation of the Collection
  *
  * @return array
  */
 public function toArray()
 {
     return $this->items->toArray();
 }
开发者ID:cermat,项目名称:valueobjects,代码行数:9,代码来源:Collection.php

示例4: hashToArgsArray

 /**
  * Loops through constructor args and buid an ordered array of args using
  * the option values passed in. We assume the passed in array has been resolved already.
  * i.e. That the arg name has an entry in the option array.
  *
  * @param  array $hashOfOptions array of options
  * @return array array of ordered args
  */
 public function hashToArgsArray($hashOfOptions)
 {
     $optionsArray = new \SplFixedArray(count($hashOfOptions));
     foreach ($this->constructorArgs as $name => $param) {
         $optionsArray[$param->getPosition()] = $hashOfOptions[$name];
     }
     return $optionsArray->toArray();
 }
开发者ID:lightglitch,项目名称:monolog-cascade,代码行数:16,代码来源:ConstructorResolver.php

示例5: castFixedArray

 public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
 {
     $a += array(Caster::PREFIX_VIRTUAL . 'storage' => $c->toArray());
     return $a;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:5,代码来源:SplCaster.php

示例6: note

 /**
  * @param string $note
  * @param int    $octave
  * @param number $duration
  *
  * @return Sample
  */
 public function note($note, $octave, $duration)
 {
     $result = new \SplFixedArray((int) ceil($this->getSampleRate() * $duration * 2));
     $octave = min(8, max(1, $octave));
     $frequency = Note::get($note) * pow(2, $octave - 4);
     $attack = $this->generator->getAttack($this->getSampleRate(), $frequency, $this->getVolume());
     $dampen = $this->generator->getDampen($this->getSampleRate(), $frequency, $this->getVolume());
     $attackLength = (int) ($this->getSampleRate() * $attack);
     $decayLength = (int) ($this->getSampleRate() * $duration);
     for ($i = 0; $i < $attackLength; $i++) {
         $value = $this->getVolume() * ($i / ($this->getSampleRate() * $attack)) * $this->getGenerator()->getWave($this->getSampleRate(), $frequency, $this->getVolume(), $i);
         $result[$i << 1] = Helper::packChar($value);
         $result[($i << 1) + 1] = Helper::packChar($value >> 8);
     }
     for (; $i < $decayLength; $i++) {
         $value = $this->getVolume() * pow(1 - ($i - $this->getSampleRate() * $attack) / ($this->getSampleRate() * ($duration - $attack)), $dampen) * $this->getGenerator()->getWave($this->getSampleRate(), $frequency, $this->getVolume(), $i);
         $result[$i << 1] = Helper::packChar($value);
         $result[($i << 1) + 1] = Helper::packChar($value >> 8);
     }
     return new Sample($result->getSize(), implode('', $result->toArray()));
 }
开发者ID:nkolosov,项目名称:wav,代码行数:28,代码来源:SampleBuilder.php

示例7: all

 /**
  * @return array
  */
 public function all()
 {
     return $this->set->toArray();
 }
开发者ID:nmarley,项目名称:bitcoin-php,代码行数:7,代码来源:MutableCollection.php

示例8: getCards

 /**
  * @return Card[]
  */
 public function getCards() : array
 {
     return $this->cards->toArray();
 }
开发者ID:ranpafin,项目名称:phpoker,代码行数:7,代码来源:Hand.php

示例9: testMaxNumberOfKeys

 /**
  * @covers Intacct\Functions\Common\ReadRelated::setKeys
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Keys count cannot exceed 100
  */
 public function testMaxNumberOfKeys()
 {
     $keys = new \SplFixedArray(101);
     $read = new ReadRelated('unittest');
     $read->setKeys($keys->toArray());
 }
开发者ID:Intacct,项目名称:intacct-sdk-php,代码行数:11,代码来源:ReadRelatedTest.php

示例10: getList

 /**
  * @return array
  */
 public function getList()
 {
     return $this->list->toArray();
 }
开发者ID:MartialGeek,项目名称:transmission-api,代码行数:7,代码来源:TorrentIdList.php

示例11: castFixedArray

 public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
 {
     $a += array("~storage" => $c->toArray());
     return $a;
 }
开发者ID:Chaireeee,项目名称:chaireeee,代码行数:5,代码来源:SplCaster.php

示例12: _removeRawDataForIndex

 /**
  * Removes the raw data at the given index
  *
  * @param int $index
  */
 protected function _removeRawDataForIndex($index)
 {
     $basicArray = $this->rawData->toArray();
     $newArray = array_merge(array_slice($basicArray, 0, $index), array_slice($basicArray, $index + 1));
     $this->rawData = SplFixedArray::fromArray($newArray);
 }
开发者ID:marviktintor,项目名称:pos-1,代码行数:11,代码来源:Database.php

示例13: testInsertionSort

 /**
  * @dataProvider valuesDataProvider
  * @param \SplFixedArray $arr
  * @param array $expected
  */
 public function testInsertionSort(\SplFixedArray $arr, array $expected)
 {
     $selectionStrategy = new InsertionSortStrategy();
     $this->assertNotEquals($expected, $arr->toArray());
     $this->assertEquals($expected, $selectionStrategy->sort($arr)->toArray());
 }
开发者ID:valdislav,项目名称:SplFixedArray,代码行数:11,代码来源:SortStrategyTest.php

示例14:

// 获得当前节点
$array->current();
// next()
// 指针移动到下一个节点
$array->next();
// setSize(int $size)
// 重新设置阵列数组的大小
$array->setSize(10);
// getSize()
// 获得阵列数组的大小
$array->getSize();
// offsetExists(int $index)
// 判断该索引是否存在值,返回boolean
$array->offsetExists(3);
// offsetGet(int $index)
// 获得该索引对应的值
$array->offsetGet(3);
// offsetSet(int $index, mixed $value)
// 设置该索引对应的值
$array->offsetSet(6, 'value3');
// offsetUnset(int $index)
// 删除该索引对应的值
$array->offsetUnset(6);
// toArray()
// 将阵列转化成php数组
// output: Array ( [0] => [1] => 2 [2] => [3] => value2 [4] => [5] => [6] => [7] => [8] => [9] => )
$php_array = $array->toArray();
// fromArray($php_array)
// 将php数组转化成阵列
// output: SplFixedArray Object ( [0] => [1] => 2 [2] => [3] => value2 [4] => [5] => [6] => [7] => [8] => [9] => )
$spl_array = SplFixedArray::fromArray($php_array);
开发者ID:ray0916,项目名称:learn,代码行数:31,代码来源:splFixedArray.php

示例15: testMaxNumberOfNames

 /**
  * @covers Intacct\Functions\Common\ReadByName::setNames
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Names count cannot exceed 100
  */
 public function testMaxNumberOfNames()
 {
     $names = new \SplFixedArray(101);
     $readByName = new ReadByName('unittest');
     $readByName->setNames($names->toArray());
 }
开发者ID:Intacct,项目名称:intacct-sdk-php,代码行数:11,代码来源:ReadByNameTest.php


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