Home :: International :: Manuals :: Howto :: FAQ :: Man Pages :: Email Login

 
 

 

array_pad

(PHP 4 , PHP 5)

array_pad --  Vergrößert ein Array auf die spezifizierte Länge mit einem Wert

Beschreibung

array array_pad ( array input, int pad_size, mixed pad_value)

array_pad() liefert eine Kopie von input, welche auf die von pad_size spezifizierte Größe mit dem Wert pad_value erweitert wurde. Ist der Parameter pad_size positiv, wird das Array rechts erweitert, ist er negativ, dann erfolgt die Erweiterung links. Ist der absolute Wert von pad_size kleiner oder gleich der Länge von input, erfolgt keine Erweiterung.

Beispiel 1. array_pad()

<?php
$input
= array (12, 10, 9);

$result = array_pad ($input, 5, 0);
// Ergebnis ist array (12, 10, 9, 0, 0)

$result = array_pad ($input, -7, -1);
// Ergebnis ist array (-1, -1, -1, -1, 12, 10, 9)

$result = array_pad ($input, 2, "noop");
// nicht erweitert
?>

 
 
 
 
Google
  Web Linuxinfor   
 

Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account

Document on this page is part of "PHP Handbuch". See Index Page for more info about Authorship and Copyright.

1999-2009 Linuxinfor.com. No rights reserved.