Maxxus PRO SPK-23 Especificaciones Pagina 118

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 893
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 117
TABLE 3.1 Allowed extract_types for extract()
Type Meaning
EXTR_OVERWRITE Overwrites the existing variable when a collision occurs.
EXTR_SKIP Skips an element when a collision occurs.
EXTR_PREFIX_SAME Creates a variable named $prefix_key when a collision
occurs. You must supply prefix.
EXTR_PREFIX_ALL Prefixes all variable names with prefix. You must supply
prefix.
The two most useful options are the default (
EXTR_OVERWRITE) and EXTR_PREFIX_ALL. The
other two options might be useful occasionally when you know that a particular collision will
occur and want that key skipped or prefixed. A simple example using EXTR_PREFIX_ALL fol-
lows. You can see that the variables created are called prefix-underscore-keyname.
$array = array( “key1” => “value1”, “key2” => “value2”, “key3” => “value3”);
extract($array, EXTR_PREFIX_ALL, “myPrefix”);
echo “$myPrefix_key1 $myPrefix_key2 $myPrefix_key3”;
This code will again produce the output: value1 value2 value3.
Note that for extract() to extract an element, that elements key must be a valid variable
name, which means that keys starting with numbers or including spaces will be skipped.
Further Reading
This chapter covers what we believe to be the most useful of PHPs array functions. We have
chosen not to cover all the possible array functions. The online PHP manual available at
http://www.php.net has a brief description of each of them.
Next
In the next chapter, we look at string processing functions. We will cover functions that search,
replace, split, and merge strings, as well as the powerful regular expression functions that can
perform almost any action on a string.
Using PHP
P
ART I
92
05 7842 CH03 3/6/01 3:42 PM Page 92
Vista de pagina 117
1 2 ... 113 114 115 116 117 118 119 120 121 122 123 ... 892 893

Comentarios a estos manuales

Sin comentarios