$r = "";
$j = 0;
foreach ($orgs as $k => $v) {
echo "\n\r" . $v->id . "\n\r";
if (1) { //you don't really need this, because it's allways true
$a_view_modl = ArticleView :: model($v->id, $v->id);
$connection = $a_view_modl->getDbConnection();
if $orgs
is an associative array, it becomes:
$r = "";
$j = 0;
for($i = 0; $i < count($orgs); $i++)
{
echo "\n\r" . $orgs[$i]->id . "\n\r";
$a_view_modl = ArticleView :: model($orgs[$i]->id, $orgs[$i]->id);
$connection = $a_view_modl->getDbConnection();
}
better you do some checks first if you go for this solution.
if you implement your solution with foreach
which is in this case more readable, you can increment or decrement a given variable, like normal:
$i++; //if you want the increment afterwards
++$i; //if you want the increment before you read your variable
the same for decrements:
$i--; //decrement after reading the variable
--$i; //decrement before you read the variable