1

I wanna use values in array of array like:

$result  = $conn->query("SELECT performer,file_id,title,duration FROM 
    databasebot WHERE performer = '$message' or title = '$message'");

$poets = array(
    "keyboard" => array()
);


while ($row = mysqli_fetch_row($result)) {        
    $poets['keyboard'][] = array($row[2],$row[1]);         
}

I wanna echo $poets values of $row[1]. How can I do that?

4
  • We need some context. Where did $poets come from? Commented Nov 9, 2017 at 17:28
  • Why too many levels/depth of array? [] and array()? Commented Nov 9, 2017 at 17:29
  • @Thamilan He's creating a 2-dimensional array. [] is to push onto the keyboard array. Commented Nov 9, 2017 at 17:29
  • @BonsaiOak edited Commented Nov 9, 2017 at 17:33

1 Answer 1

2

Loop through the array in $poets['keyboard']. In each element, $poets[1] will be in the [1] sub-element.

foreach ($poets['keyboard'] as $kb) {
    echo $kb[1];
}
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.