Skip to content

Instantly share code, notes, and snippets.

@jimjamdev
Created July 16, 2015 12:55
Show Gist options
  • Save jimjamdev/f4daa50fe511350b7697 to your computer and use it in GitHub Desktop.
Save jimjamdev/f4daa50fe511350b7697 to your computer and use it in GitHub Desktop.
Comparing arrays in Yii
$settings = CHtml::listData(GeneralSettings::model()->findAll("`group` = 'email'"), "setting", "value");
$collectLogData = array(
"emailServer" => $post["emailServer"],
"emailPort" => $post["emailPort"],
"emailUsername" => $post["emailUsername"],
"emailPassword" => $post["emailPassword"],
"emailEncryption" => $post["encryption"],
"emailAuth" => $post["emailAuthentication"],
);
// Compare posted data array with currently saved settings array, and remove key if no difference
$compareData = array_diff($collectLogData, $settings);
$logData = $compareData;
$logList = '<br><br><ul class="list">';
foreach ($logData as $key=>$value) {
$logList .= '<li>' . $key . ': ' . $value . '</li>';
}
$logList .= '</ul>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment