【发布时间】:2014-06-11 22:36:00
【问题描述】:
我设置了这个页面,它可以为我登录网站并将新内容下载到我的服务器。我希望它为多个帐户执行此操作,只要我的浏览器打开页面,就可以无限期地继续执行此操作。
在脚本中,我创建这样的连接:$connection = new Connection('myusername','pass');
也就是说,我想取出我的信用,然后将变量放在那里。上面我想声明一个用户名/密码组合数组,但我不知道如何访问索引。该数组将类似于:
<?php
$accounts = array(
"foo" => "bar",
"bar" => "foo!",
"foo" => "foo"
"bar" => "bar"
//100 => -100,
//-100 => 100,
);
//var_dump($array);
?>
所以循环应该类似于
<?php
for ($i=0; $i<=count($accounts); $i++) {
//set the first value to username, *****
//set the second value to password *****
//create my connection based on these variables
//do the rest of my steps
}
?>
带星号的行是我不确定的行。使用上面的数组,元素是否存储为 $accounts[0][0] == 'foo', $accounts[0][0] == 'bar' ?
建议?
【问题讨论】:
标签: php arrays loops indexing iteration