mathi mathi - 7 months ago 10
PHP Question

store array values in another array using for loop in php

store array values in another array using for loop in php

$sql = "select id,user_email,username,full_name from registration";
$connection = Yii::app()->db;
$command = $connection->createCommand($sql);
$rows = $command->queryAll();
$email_arr = [];
for ($i=0; $i <=count($rows); $i++) {
$email_arr[] = $rows[$i]['user_email'];
}


i am getting undefined offset 39 php error anyone can help me please

Answer

for ($i=0; $i < count($rows); $i++) {

Comments