Jump to content

Replace one value of array (if empty)


amsgwp

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/280149-replace-one-value-of-array-if-empty/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.