Creating Arrays

Use array();

Arrays in PHP can contain a mix of values if you wish (e.g. strings, integers, null, arrays).

Create an empty array
  $result_search = array();

//You can add items to it like this:
  $result_search[] = "a";
  $result_search[] = "b";
  $array = array_fill(0, 24, 0);    //Fill an array from index 0, 24 items long (0-23), with default value 0
Create an array of values
  $MyArray = array('Adam', 'Bill', 'Charlie);
  echo $MyArray[1];      //Displays Bill

  //Alternative method to create the same an array:
  $MyArray = ['Adam', 'Bill', 'Charlie];

  $MyArray = array(
                   'key_name_1' => "Hello",
                   'key_name_2' => false,
                   'key_name_3' => 1234
            );

Get array value

  $MyString= $OperationUsageJson['MyString'] ?? '';
  $MyValue = $OperationUsageJson['MyValue'] ?? 0;

(Gets the array value if it exists, otherwise to an empty string/int)

Calling a function with an array of values

soem_function_name(array('group_id' => $GroupId, 'exclude_admins' => false));

Key & Value Arrays

See here.

Two Dimension Arrays

See here.

Array Length

  count($MyArray)

Is Array?

  if (!is_array($my_array))

Is Array Empty

  if (empty($my_array))

Does array index exist?

  $MyArrayValue = isset($MyArray['some_name']) ? $MyArray['some_name'] : '';

//Another example
  return isset($args['v']) ? $args['v'] : false;

//Another example
  if (isset($MyArray[1]))
  {
  }

Does array value exist?

  if (in_array('Test', $MyArray))
  {
    //Value exists
  }