it seems a simple question but I cannot remember why:
so... I have an array on $_POST and I want to make a echo of that variable:
Im doing this:
function h()
{
foreach($_POST as $k => $v ){
echo $v;
}
Thats fine but I have a problem:
The $POST should be expecting two or more values, for example:
Array ( [s-armenia] => TRIBUNAL ADMINISTRATIVO DE SUCRE [s-armenia2] => 0 )
so.. with my function I get this:
TRIBUNAL ADMINISTRATIVO DE SUCRE
0
¿How echo my function without the 0?
Thanks in advance for your help.
Thanks guys for your help, I think about something simple like this and it works:
function h()
{
foreach($_POST as $k)
{
$p = "/0/";
$s = "";
echo preg_replace($p, $s, $k);
}
}
foreach($_POST as $k)
{
echo $k;
}
=> $v would be the key (which is 0)
your array should look like array(1 => 2, 3 => array(3.1 => 3.2), 4 => 5)
edit: adding from PHP manual:
<?php
$array = array(
"foo" => "bar",
42 => 24,
"multi" => array(
"dimensional" => array(
"array" => "foo"
)
)
);
var_dump($array["foo"]);
var_dump($array[42]);
var_dump($array["multi"]["dimensional"]["array"]);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.