PHP get both array value and array key

后端 未结 4 1141
日久生厌
日久生厌 2020-12-02 20:40

I want to run a for loop through an array and create anchor elements for each element in the array, where the key is the text part and the value is the URL.

How can

4条回答
  •  难免孤独
    2020-12-02 20:56

    This should do it

    foreach($yourArray as $key => $value) {
        //do something with your $key and $value;
        echo '' . $key . '';
    }
    

    Edit: As per Capsule's comment - changed to single quotes.

提交回复
热议问题