Documentation

TrimArr

bool
TrimArr(
 array &arr,
 bool trim_value=false
);

The function deletes all elements with empty values from the array. Returns true, if at least one empty element was deleted, otherwise returns false. The function works only with linear arrays.

Function parameters

ParameterDescription
arr Source array. This parameter is set as a link to an original variable.
trim_value Optional. By default, set as false. If true is passed, trim() function is applied to each array element.

Example of use

<?
$ar = array(
  "a" => "1",
  "b" => " ",
  "c" => "",
  "d" => "2"
);
TrimArr($ar);
// array $ar will look as the array("a" => "1", "d" => "2")
?>


© «Bitrix24», 2001-2024
Up