Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
多数组上的php数组迭代_Php_Arrays - Fatal编程技术网

多数组上的php数组迭代

多数组上的php数组迭代,php,arrays,Php,Arrays,您好,我有下面列出的4个数组。有谁能告诉我如何打印每个数组的0和第3个索引值吗 Array ( [0] => 7406072674 [1] => [2] => [3] => Dear Student, FlipTutor has credited 10 FREE coins. Connect with expert teacher and clear your doubts. Install App - http://bit.ly/1

您好,我有下面列出的4个数组。有谁能告诉我如何打印每个数组的0和第3个索引值吗

Array
(
    [0] => 7406072674
    [1] => 
    [2] => 
    [3] => Dear Student,  FlipTutor has credited 10 FREE coins. Connect with expert teacher and clear your doubts. Install App - http://bit.ly/1WIaNKD
    [4] => 139
    [5] => 0
)
Array
(
    [0] => 7676731030
    [1] => hkjhk
    [2] => hgk
    [3] => Dear Nishant, FlipTutor has credited 10 FREE coins. Connect with expert teacher and clear your doubts. Install App - http://bit.ly/1WIaNKD
    [4] => 138
    [5] => 0
)
Array
(
    [0] => 9738040711
    [1] => ljlhkhjk
    [2] => khgkj
    [3] => Dear Sonu, FlipTutor has credited 10 FREE coins. Connect with expert teacher and clear your doubts. Install App - http://bit.ly/1WIaNKD
    [4] => 135
    [5] => 0
)
Array
(
    [0] => 9949942011
    [1] => anil
    [2] => sdfsd
    [3] => Dear Anil, FlipTutor has credited 10 FREE coins. Connect with expert teacher and clear your doubts. Install App - http://bit.ly/1WIaNKD
    [4] => 123
    [5] => 1
)

你有没有试过一些方法来达到你的目标?还有,预期的输出是什么?感谢您的回复,我想打印每个数组[0]和[3]索引值。请在您的问题中包括相关信息,例如,您想为每个数组:
[0][3][0][3]…
还是先打印所有
[0]
,然后打印所有
[3]
?还应在问题中加入您当前的尝试。您应该自己尝试这样做,然后在遇到问题时返回:)查看
foreach
。循环遍历每个数组,然后打印0和3个索引。但是,这会给您提供多个
foreach
循环。然后,您可以将其提取到只包含一个foreach循环的函数中,并将数组作为要循环的值传递给它。values
E\u警告:类型2——为foreach()提供的参数无效。
。当然,Jk……虽然这个代码片段可以解决这个问题,但它确实有助于提高文章的质量。请记住,您将在将来回答读者的问题,这些人可能不知道您的代码建议的原因。
$arrays = "YOUR 4 ARRAYS";

foreach ($arrays as $array) {
    $newArray[]=$array[0];
    $newArray[]=$array[3];
}

var_dump($newArray);