PHP: Condition for field key value
How do I declare a condition for a field key value. I have a custom field and part of this statement is used to开发者_如何学编程 display its value...
function SINGLE_CUSTOMFIELDS($post,$FieldValues){
global $wpdb,$PPT;$row=1;
if($FieldValues ==""){
$FieldValues = get_option("customfielddata");
}
if(is_array($FieldValues)){
print "<div class='offer-info'>";
foreach($FieldValues as $key => $field){
if(isset($field['show']) && $field['enable'] == 1 ){
$imgArray = array('jpg','gif','png', 'swf');
$value = $PPT->GetListingCustom($post->ID,$field['key'] );
if(is_array($value) || strlen($value) < 1){ }else{
if($field['key'] == "Zipcode"){
print "<div style='display:none'><p><br />";
print "<b>".$field['name']."</b></p><p><br />";
}
I want to set a condition for the field key Zipcode that is equal to a value (Ex. 33138)
I was thinking that it would be something like this:
if($field['key'] == "Zipcode" => "33138"){
print "Print something";
}
But apparently this is wrong. I would appreciate if someone showed how to set a condition for a specific field key value. And also for multiple field keys in the condition statement.
Thanks a lot.
I'm not entirely sure this is what you mean by "field key", but how about accessing it by name?
if ($field["Zipcode"] == "33138") {
print "Print something";
}
精彩评论