1

I'm trying to replace this array:

$lts = ['20', '21'];

with an array from the database. I've tried a few things with no avail. Here's what I've got now:

$query = "SELECT id FROM members WHERE admin = '2'";
$lts = mysqli_fetch_all($con->query($query), MYSQLI_NUM);

When I var_dump it its giving me this:

array (size=2)
  0 => 
    array (size=1)
      0 => string '20' (length=2)
  1 => 
    array (size=1)
      0 => string '21' (length=2)

I need it to give me this:

array (size=2)
  0 => string '20' (length=2)
  1 => string '21' (length=2)

Any idea on how to get the latter array?

2
  • I'm trying to keep in within the $lts variable. Commented Apr 24, 2017 at 0:44
  • could you post an answer on how to do that. Commented Apr 24, 2017 at 0:46

1 Answer 1

1

I just notice your returning array is same as the array you got, never mind run this code

//run loop on your array after your query
for($i=0; $i<count($lts); $i++){
    for($j=0; $j<count($lts[$i]); $j++){
        $lts[$i]=$lts[$i][$j];

    }
}
echo '<pre>';
print_r($lts);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.