Ivan Zugec

Drupal Consultant

Helpful php array functions

Just when you think you know php. You find these helpful array function.

in_array()
http://au2.php.net/in_array

array_key_exists()
http://au.php.net/array_key_exists

more array functions:
http://au.php.net/manual/en/ref.array.php

$value = array( [0] => 6 [1] => 5 [2] => 4 );
$k = 4;

$checked = false;
if(is_array($value))
{
if(in_array($k, $value))
{
$checked = true;
}
else
{
$checked = false;
}
}

About the author: Ivan Zugec
Ivan Zugec's picture

Ivan is a Sydney Australia based Drupal Developer with over 5 years experience.

Follow:
Category: 

Add new comment