我想只提取名称的某个部分并测试它是否设置(isset)?
特别适用于largeImage_ 1 ,largeImage_ 2 等。
这是我尝试过的,但它似乎没有回归或测试。
if ($_POST['tutorial']) {
foreach ( $_POST['tutorial'] as $key => $value ) {
if ('largeImage' === substr($key, 0 , 10) )
{
echo $value;
}
}
}
Array
(
[title] => title
[tutorial] => Array
(
[1] => Array
(
[largeImage_1] => Array
(
[0] => image.png
[1] => image.png
)
)
[2] => Array
(
[largeImage_2] => Array
(
[0] => image.png
)
)
)
[name] => "";
)
答案 0 :(得分:1)
你需要在另一个循环中使用循环来访问像'largeImage_1','largeImage_2'这样的键。
if ($_POST['tutorial']) {
foreach ( $_POST['tutorial'] as $key => $value ) {
foreach ( $value as $k => $v ) {
if ('largeImage' === substr($k, 0 , 10) )
{
//your code here
}
}
}
}