本文整理汇总了PHP中RemoveKeysFromNestedArray函数的典型用法代码示例。如果您正苦于以下问题:PHP RemoveKeysFromNestedArray函数的具体用法?PHP RemoveKeysFromNestedArray怎么用?PHP RemoveKeysFromNestedArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RemoveKeysFromNestedArray函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RenderData
public function RenderData($Data = NULL)
{
if ($Data === NULL) {
$Data = array();
// Remove standard and "protected" data from the top level.
foreach ($this->Data as $Key => $Value) {
if (in_array($Key, array('Title'))) {
continue;
}
if (isset($Key[0]) && $Key[0] == '_') {
continue;
}
// protected
$Data[$Key] = $Value;
}
}
// Massage the data for better rendering.
foreach ($Data as $Key => $Value) {
if (is_a($Value, 'Gdn_DataSet')) {
$Data[$Key] = $Value->ResultArray();
}
}
// Remove values that should not be transmitted via api
$Remove = array('Email', 'Password', 'HashMethod', 'DateOfBirth', 'TransientKey', 'Permissions', 'Attributes');
if (!Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) {
$Remove[] = 'InsertIPAddress';
$Remove[] = 'UpdateIPAddress';
$Remove[] = 'LastIPAddress';
}
$Data = RemoveKeysFromNestedArray($Data, $Remove);
// Make sure the database connection is closed before exiting.
$this->Finalize();
// Check for a special view.
$ViewLocation = $this->FetchViewLocation(($this->View ? $this->View : $this->RequestMethod) . '_' . strtolower($this->DeliveryMethod()), FALSE, FALSE, FALSE);
if (file_exists($ViewLocation)) {
include $ViewLocation;
return;
}
switch ($this->DeliveryMethod()) {
case DELIVERY_METHOD_XML:
header('Content-Type: text/xml', TRUE);
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$this->_RenderXml($Data);
exit;
break;
case DELIVERY_METHOD_JSON:
default:
header('Content-Type: application/json', TRUE);
if ($Callback = $this->Request->Get('callback', FALSE)) {
// This is a jsonp request.
exit($Callback . '(' . json_encode($Data) . ');');
} else {
// This is a regular json request.
exit(json_encode($Data));
}
break;
}
}
示例2: RemoveKeysFromNestedArray
function RemoveKeysFromNestedArray($Array, $Matches)
{
if (is_array($Array)) {
foreach ($Array as $Key => $Value) {
$IsMatch = FALSE;
foreach ($Matches as $Match) {
if (StringEndsWith($Key, $Match)) {
unset($Array[$Key]);
$IsMatch = TRUE;
}
}
if (!$IsMatch && (is_array($Value) || is_object($Value))) {
$Array[$Key] = RemoveKeysFromNestedArray($Value, $Matches);
}
}
} else {
if (is_object($Array)) {
$Arr = get_object_vars($Array);
foreach ($Arr as $Key => $Value) {
$IsMatch = FALSE;
foreach ($Matches as $Match) {
if (StringEndsWith($Key, $Match)) {
unset($Array->{$Key});
$IsMatch = TRUE;
}
}
if (!$IsMatch && (is_array($Value) || is_object($Value))) {
$Array->{$Key} = RemoveKeysFromNestedArray($Value, $Matches);
}
}
}
}
return $Array;
}
示例3: RenderData
public function RenderData($Data = NULL)
{
if ($Data === NULL) {
$Data = array();
// Remove standard and "protected" data from the top level.
foreach ($this->Data as $Key => $Value) {
if ($Key && in_array($Key, array('Title', 'Breadcrumbs'))) {
continue;
}
if (isset($Key[0]) && $Key[0] === '_') {
continue;
}
// protected
$Data[$Key] = $Value;
}
unset($this->Data);
}
// Massage the data for better rendering.
foreach ($Data as $Key => $Value) {
if (is_a($Value, 'Gdn_DataSet')) {
$Data[$Key] = $Value->ResultArray();
}
}
$CleanOutut = C('Api.Clean', TRUE);
if ($CleanOutut) {
// Remove values that should not be transmitted via api
$Remove = array('Password', 'HashMethod', 'TransientKey', 'Permissions', 'Attributes', 'AccessToken');
if (!Gdn::Session()->CheckPermission('Garden.Moderation.Manage')) {
$Remove[] = 'InsertIPAddress';
$Remove[] = 'UpdateIPAddress';
$Remove[] = 'LastIPAddress';
$Remove[] = 'AllIPAddresses';
$Remove[] = 'Fingerprint';
if (C('Api.Clean.Email', TRUE)) {
$Remove[] = 'Email';
}
$Remove[] = 'DateOfBirth';
}
$Data = RemoveKeysFromNestedArray($Data, $Remove);
}
if (Debug() && ($Trace = Trace())) {
// Clear passwords from the trace.
array_walk_recursive($Trace, function (&$Value, $Key) {
if (in_array(strtolower($Key), array('password'))) {
$Value = '***';
}
});
$Data['Trace'] = $Trace;
}
// Make sure the database connection is closed before exiting.
$this->EventArguments['Data'] =& $Data;
$this->Finalize();
// Add error information from the form.
if (isset($this->Form) && sizeof($this->Form->ValidationResults())) {
$this->StatusCode(400);
$Data['Code'] = 400;
$Data['Exception'] = Gdn_Validation::ResultsAsText($this->Form->ValidationResults());
}
// $this->SendHeaders();
// Check for a special view.
$ViewLocation = $this->FetchViewLocation(($this->View ? $this->View : $this->RequestMethod) . '_' . strtolower($this->DeliveryMethod()), FALSE, FALSE, FALSE);
if (file_exists($ViewLocation)) {
include $ViewLocation;
return;
}
// Add schemes to to urls.
if (!C('Garden.AllowSSL') || C('Garden.ForceSSL')) {
$r = array_walk_recursive($Data, array('Gdn_Controller', '_FixUrlScheme'), Gdn::Request()->Scheme());
}
@ob_clean();
switch ($this->DeliveryMethod()) {
case DELIVERY_METHOD_XML:
safeHeader('Content-Type: text/xml', TRUE);
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$this->_RenderXml($Data);
return TRUE;
break;
case DELIVERY_METHOD_PLAIN:
return TRUE;
break;
case DELIVERY_METHOD_JSON:
default:
if (($Callback = $this->Request->Get('callback', FALSE)) && $this->AllowJSONP()) {
safeHeader('Content-Type: application/javascript', TRUE);
// This is a jsonp request.
echo $Callback . '(' . json_encode($Data) . ');';
return TRUE;
} else {
safeHeader('Content-Type: application/json', TRUE);
// This is a regular json request.
echo json_encode($Data);
return TRUE;
}
break;
}
return FALSE;
}