-2

pls, i would like to get the values of the $aa variable, i'm using the mysqli_fetch_all because all the values need to be used in another layer. Thanks

$aa = mysqli_fetch_all($ttt,MYSQLI_ASSOC);

Output with var_dump($aa):

array(2) { [0]=> array(1) { ["followe"]=> string(8) "bammyww " } [1]=> array(1) { ["followe"]=> string(5) "demo " } }

i have tried using $aa['followe'] , but i'm getting invalid index error.

LF00
  • 27,015
  • 29
  • 156
  • 295
boost
  • 25
  • 6
  • Possible duplicate of [How to get a single value from a query result in php](http://stackoverflow.com/questions/30844569/how-to-get-a-single-value-from-a-query-result-in-php) – mickmackusa May 18 '17 at 04:12

4 Answers4

1

Just loop through it. It's an array containing associative arrays.

foreach($aa as $item)
{
    $item['followe'] // do something with this.
}
A. L
  • 11,695
  • 23
  • 85
  • 163
0

Instead of $aa['followe'], try:

$aa[0]['followe'];

as its a multi-dimension array. And the right approach to get all the array element is using foreach() like:

foreach($aa as $item)
{
    $item['followe']
}
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
0

use

$aa[0]['followe'];

$aa[0] is array(1) { ["followe"]=> string(8) "bammyww " }

$aa[0]['followe'] is string(8) "bammyww "

LF00
  • 27,015
  • 29
  • 156
  • 295
0

You can also use array_column as

array_column($aa,'followe');//retrieves values associated with the key followe

Rotimi
  • 4,783
  • 4
  • 18
  • 27
  • i got this array(2) { [0]=> string(8) "bammyww " [1]=> string(5) "demo " } , how do i get the bammyww and demo – boost May 18 '17 at 04:42
  • To get bammyww, do print_r($array[0]); replace the array variable with yours – Rotimi May 18 '17 at 05:23