Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Replace one value of array (if empty)

$
0
0

This code should be pretty self explanatory, but I'm struggling bad to get it to work. I want to check if the "propview" element is blank, if so, replace it with "No Contingencies". Simple right? 

$details_array = array( "propview"         => JText::_('COM_IPROPERTY_PROPVIEW' ),
			     "beds"         => JText::_('COM_IPROPERTY_BEDS' ),
                 "baths"        => JText::_('COM_IPROPERTY_BATHS' ),
                 "sqft"         => (!$this->settings->measurement_units) ? JText::_('COM_IPROPERTY_SQFT' ) : JText::_('COM_IPROPERTY_SQM' ),
                 "lotsize"      => JText::_('COM_IPROPERTY_LOT_SIZE' ),
                 "lot_acres"    => JText::_('COM_IPROPERTY_LOT_ACRES' ),
                 "yearbuilt"    => JText::_('COM_IPROPERTY_YEAR_BUILT' ),
                 "heat"         => JText::_('COM_IPROPERTY_HEAT' ),
                 "garage_type"  => JText::_('COM_IPROPERTY_GARAGE_TYPE' ),
                 "roof"         => JText::_('COM_IPROPERTY_ROOF' ));
if(empty($details_array["propview"]))
{
$details_array = array(
	"propview" => "No Contingencies"
	);
}

It either doesn't do anything or it wipes out the entire array. Maybe the logic should be embedded in the original array, but I haven't found any examples that show that ever being done.


Viewing all articles
Browse latest Browse all 13200

Trending Articles