我正在尝试合并代码的两个部分。为此,我必须将我多次调用的函数的回显数组列输出存储到一个或多个我可以执行计算的数组中。
这是我正在尝试做的事情:
<?php
$searchquery[1] ="jupiter";
$searchquery[2] ="venus";
//can be multiple queries
include ('find.php');
for($i=0;$i<count($searchquery);$i++)
{
find($searchquery[$i]);
}
/find.php echoes back to me a MySQL query which then
creates a 2 dimensional array for me called
/$searchresult which looks like this as an example
t x (let's call first column t for example, and second x)
|1|3|
|1|4|
|2|6|
|4|8|
|7|1|
and it echoes it back to me, this works.
But, i need to use the first column (t) (11247) output from find.php
which was the result of the searchquery "jupiter",
and i need to store it as some sort of array in this current sheet,
theni need to store the "venus" searchquery which is let's say
t x
|1|3|
|2|4|
|3|4|
|4|6|
|5|4|
并将第一列 (t) 作为数组存储在当前工作表中。
我正在尝试将 find.php 函数的回声存储为数组,以便我可以在当前工作表中执行以下操作:
$venusarrayt = array(1, 1, 2, 4, 7); //the manually defined
//$searchresult first column output from find.php which echos to me (t) (11247)
$jupiterarrayt = array(1, 2, 3,4,5); //the manually defined
//$searchresult first column output from find.php which echos to me (t) (12345)
//I need to perform the following operation and sum all of the t combinations
for($l=0;$l<count($venusarrayt);$l++){
for($s=0;$s<count($jupiterarrayt);$s++){
echo $venusarrayt[$l]+$jupiterarrayt[$s];
这部分有效!但是我在将 echo'd$searchresult
输出合并到一个数组中时遇到了麻烦,我可以在该数组上执行上述 for 循环。在这个例子中,我通过在 php 表中键入“venusarrayt 和 jupiterarrayt”来手动完成。
我确信有某种方法可以将我多次调用的函数的回显数组列结果存储到数组中,但我还没有弄清楚如何。请帮忙。