本文整理汇总了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());
}
示例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;
}
示例3: toArray
/**
* Returns a native array representation of the Collection
*
* @return array
*/
public function toArray()
{
return $this->items->toArray();
}
示例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();
}
示例5: castFixedArray
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
{
$a += array(Caster::PREFIX_VIRTUAL . 'storage' => $c->toArray());
return $a;
}
示例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()));
}
示例7: all
/**
* @return array
*/
public function all()
{
return $this->set->toArray();
}
示例8: getCards
/**
* @return Card[]
*/
public function getCards() : array
{
return $this->cards->toArray();
}
示例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());
}
示例10: getList
/**
* @return array
*/
public function getList()
{
return $this->list->toArray();
}
示例11: castFixedArray
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
{
$a += array("~storage" => $c->toArray());
return $a;
}
示例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);
}
示例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());
}
示例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);
示例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());
}