I've just achieved a code where I make an array with foreach
and in the same code I already have an existing array. What I want to do is to make only one array with those two results. Here is my code for the first array :
$sql = "SELECT photoprofile,username from photo WHERE username IN ('somearray')";
$resol = array();
$resulol = mysqli_query($con,$sql);
$photos = mysqli_fetch_all($resulol, MYSQLI_ASSOC);
$photos = array_column($photos, "photoprofile", "username");
foreach ( $restest as $user ) {
if ( isset($photos[$user])) {
$res[] = $photos[$user];
}
else {
$res[] = '';
};
}
And here is my second array :
while($row = mysqli_fetch_array($result)){
array_push($res2, array(
"name"=>$row['name'],
"publisher"=>$row['username'],
"image"=>$row['photo'],
)
);}
If you have any tips, any comment or even a question (if I wasn't clear enough for you), just ask me ! Thanks !
Edit : What I want to make is an array of this type :
[{"name":"usera","publisher":"Jeana","image":"urla",""photouser","url2a"},{"name":"userb","publisher":"Jeanb","image":"urlb","photouser","url2b"}]