Vous êtes ici Fonction PHP > Description de la fonction is_array()

 

Recherche sur les Noms des fonctions php/mysql

 
 

is_array()

Définition

Détermine si une variable est un tableau - (PHP 4, PHP 5)

Description

bool is_array ( mixed $var )

is_array() détermine si la variable donnée est un tableau.

Liste de paramètres

var

La variable à évaluer.

Valeurs de retour

Retourne TRUE si var est un array, FALSE sinon.

Exemples

Exemple #1 Exemple avec is_array()

<?php
$yes 
= array('ceci''est''un tableau');

echo 
is_array($yes) ? 'Tableau' 'ce n\'est pas un tableau';
echo 
"\n";

$no 'ceci est une chaîne';

echo 
is_array($no) ? 'Tableau' 'ce n\'est pas un tableau';
?>

L'exemple ci-dessus va afficher :

Tableau
ce n'est pas un tableau



 
 

Bouts de code utilisant la fonction is_array()



<?php /* ... */                 // Item is not an array                 if (!is_array($item))                     { /* ... */ ?>

<?php /* ... */   private function safe_encode($data) {     if (is_array($data)) {       return array_map(array($this'safe_encode'), $data); /* ... */ ?>

<?php /* ... */ // si ce n'est pas un tableau la fonction renvoie FALSE     if (!is_array($array))          return false/* ... */ ?>

<?php /* ... */ {     if (!is_array($tab)) return false;     $string "array"; /* ... */ ?>

<?php /* ... */         $indent = (isset($args[2])) ? $args[2] : '';         If (is_array($args[0]))         { /* ... */ ?>