本文整理汇总了PHP中Arr::key_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::key_exists方法的具体用法?PHP Arr::key_exists怎么用?PHP Arr::key_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::key_exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: active
/**
* Returns whether the model's status is active.
*
* @return bool
*/
public function active()
{
if (!Arr::key_exists($this::properties(), 'status')) {
return false;
}
return $this->status == 'active';
}
示例2: test_key_exists_with_dot_separated_key
/**
* Tests Arr::key_exists()
*
* @test
* @dataProvider person_provider
*/
public function test_key_exists_with_dot_separated_key($person)
{
$expected = true;
$output = Arr::key_exists($person, "location.city");
$this->assertEquals($expected, $output);
}
示例3: get_contact
/**
* Attempts to get a contact from a given ID.
*
* @param int $id Contact ID.
*
* @return \Model_Contact
*/
protected function get_contact($id)
{
if (!$id) {
throw new HttpNotFoundException();
}
$contact = \Service_Contact::find_one($id);
if (!$contact || !\Arr::key_exists(\Seller::active()->contacts, $contact->id)) {
throw new HttpNotFoundException();
}
return $contact;
}
示例4: encode
/**
* Function to encode input array depending on the content type
*
* @param array $input
* @return mixed encoded output
*/
protected function encode(array $input)
{
// Detect the request content type, default to 'text/plain'
$content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain');
// Get the correct format for the current content type
$format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null;
switch ($format) {
// Format as XML
case 'xml':
/**
* If the input array has one item in the top level
* then use that item as the root XML element.
*/
if (count($input) === 1) {
$base_node = key($input);
return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
} else {
return \Format::forge($input)->to_xml();
}
break;
// Format as JSON
// Format as JSON
case 'json':
return \Format::forge($input)->to_json();
break;
// Format as PHP Serialized Array
// Format as PHP Serialized Array
case 'serialize':
return \Format::forge($input)->to_serialize();
break;
// Format as PHP Array
// Format as PHP Array
case 'php':
return \Format::forge($input)->to_php();
break;
// Format as CSV
// Format as CSV
case 'csv':
return \Format::forge($input)->to_csv();
break;
default:
if (count($input) === 1 and key($input) === 'form-data') {
// multipart/form-data
return $input['form-data'];
} else {
//application/x-www-form-urlencoded
return http_build_query($input, null, '&');
}
break;
}
}