本文整理汇总了PHP中Arr::pick方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::pick方法的具体用法?PHP Arr::pick怎么用?PHP Arr::pick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::pick方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
/**
* Get edit form.
*
* @return string
*/
public function form()
{
ob_start();
// Map options
$options = array('marker' => HTML::chars($this->venue->name), 'infowindow' => HTML::chars($this->venue->address) . '<br />' . HTML::chars($this->venue->city_name), 'lat' => $this->venue->latitude, 'long' => $this->venue->longitude);
// Form
echo Form::open(Route::url('venue', array('id' => Route::model_id($this->venue), 'action' => 'foursquare')), array('id' => 'form-foursquare-link', 'style' => 'display: none'));
?>
<fieldset>
<?php
echo Form::control_group(Form::input('city_name', $this->venue->city_name, array('class' => 'input-large')), array('city_name' => __('City')));
?>
<?php
echo Form::control_group(Form::input('name', $this->venue->name, array('class' => 'input-large', 'placeholder' => __('Fill city first'))), array('name' => __('Name')));
?>
<?php
echo Form::control_group(Form::input('address', $this->venue->address, array('class' => 'input-large', 'placeholder' => __('Fill venue first'))), array('address' => __('Address')));
?>
<?php
echo Form::control_group(Form::input('foursquare_id', $this->venue->foursquare_id, array('class' => 'input', 'readonly' => 'readonly')), array('foursquare_id' => __('Foursquare ID')));
?>
<?php
echo Form::control_group(Form::input('foursquare_category_id', $this->venue->foursquare_category_id, array('class' => 'input', 'readonly' => 'readonly')), array('foursquare_category_id' => __('Foursquare Category ID')));
?>
</fieldset>
<fieldset>
<?php
echo Form::hidden('latitude', Arr::pick($this->venue->latitude, $this->venue->city ? $this->venue->city->latitude : 0));
?>
<?php
echo Form::hidden('longitude', Arr::pick($this->venue->longitude, $this->venue->city ? $this->venue->city->longitude : 0));
?>
<?php
echo Form::csrf();
?>
<?php
echo Form::button('save', __('Link'), array('type' => 'submit', 'class' => 'btn btn-success'));
?>
</fieldset>
<?php
echo Form::close();
?>
<script>
head.ready('anqh', function hookFoursquare() {
$("#link-foursquare").on('click', function linkFoursquare(event) {
event.preventDefault();
$(this).hide();
$('#foursquare .alert').hide();
$('#form-foursquare-link').show('fast');
$('#map').show('fast', function toggleMap() {
$('#map').googleMap(<?php
echo json_encode($options);
?>
);
});
});
$('[name=city_name]:input').autocompleteGeo();
$('[name=name]:input').foursquareVenue({
venueId: 'foursquare_id',
categoryId: 'foursquare_category_id',
latitudeSearch: 'latitude',
longitudeSearch: 'longitude'
});
});
</script>
<?php
return ob_get_clean();
}
示例2: average
/**
* get the average of the items
*
* @param array[array] $array
* @param string $key
*/
public static function average($array, $key = null)
{
if (!is_array($array)) {
throw new \InvalidArgumentException('Arr::average - first argunent has to be an array.');
}
if (is_string($key) && Arr::is_multi($array)) {
$array = Arr::pick($key, $array);
}
return static::sum($array) / count($array);
}