本文整理汇总了PHP中Collection::getCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getCollection方法的具体用法?PHP Collection::getCollection怎么用?PHP Collection::getCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::getCollection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCollection
public function setCollection(Collection $collection)
{
$this->_collection = $collection->getCollection();
}
示例2: getCollection
public function getCollection()
{
$this->load();
return parent::getCollection();
}
示例3: offsetUnset
$this->collection[] = $value;
} else {
$this->collection[$index] = $value;
}
}
public function offsetUnset($index)
{
unset($this->collection[$index]);
}
}
$numbers = ['a', 'b', 'c', 'd'];
// using collection
echo 'Collection:<br>';
$numbersCollection = new Collection($numbers);
echo 'After initialisation<br>';
var_dump($numbersCollection->getCollection());
echo '<hr>';
$numbersCollection[4] = 'e';
echo 'After setting [4]<br>';
var_dump($numbersCollection->getCollection());
echo '<hr>';
$numbersCollection[] = 'f';
echo 'After setting []<br>';
var_dump($numbersCollection->getCollection());
echo '<hr>';
echo '<br><br><br>';
// using array
echo 'Array:<br>';
echo 'After initialisation<br>';
var_dump($numbers);
echo '<hr>';
示例4: addCollection
/**
* Adds collection to current collection
*
* @param Collection $collection
*
* @return void
*/
public function addCollection(Collection $collection)
{
$this->initialize(array_merge($this->getCollection(), $collection->getCollection()));
}
示例5: offsetUnset
echo "offsetSet() called with [{$index}], [{$value}]<br>";
if (is_null($index)) {
$this->collection[] = $value;
} else {
$this->collection[$index] = $value;
}
}
public function offsetUnset($index)
{
unset($this->collection[$index]);
}
}
echo '<h3>initialise</h3>';
$numbers = ['tahi', 'rua', 'toru', 'wha'];
$numbersCollection = new Collection($numbers);
printf('Collection after initialisation: %s<br>', json_encode($numbersCollection->getCollection()));
echo '<hr>';
echo '<h3>foreach()</h3>';
foreach ($numbersCollection as $number) {
echo "{$number}<br>";
}
echo '<hr>';
echo '<h3>set</h3>';
$numbersCollection[4] = 'rima';
printf('Collection after setting [4]: %s<br>', json_encode($numbersCollection->getCollection()));
for ($i = 0; $i < count($numbersCollection); $i++) {
printf('%s<br>', $numbersCollection[$i]);
}
echo '<hr>';
echo '<h3>append</h3>';
$numbersCollection[] = 'ono';