Jump to content

Replace one value of array (if empty)


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' ));
$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.