How to operate on array elements with specific key names-php Tutorial

Source: Internet
Author: User
How to operate on the array elements of a specific key name, for example, if I have an array retrieved from the database, the key name field name directly outputs this array element to the table; just use foreach, but I want to set all the elements of a specific key name. for example, all the elements of an array whose key name is userid & nbsp; are there any ways to add hyperlinks and output them on the table .. how to operate on array elements with specific key names
For example, I have an array extracted from the database. The key name is the field name.
Output the array element directly to the table. I will use foreach.


However, I want to add hyperlinks to all elements with specific key names, such as all array elements with key names 'userid '.
And then output it to the table.
Is there a solution ..

Share:


------ Solution --------------------
Isn't it the same? you just need to add a link to the output.
------ Solution --------------------
Foreach ($ arr as $ key => $ value ){
If ($ key = "userid "){
Echo "". $ key ."";
}
}
------ Solution --------------------
Your code has no syntax errors. can it not be displayed, or is it not what you need?

------ Solution --------------------
For example, if the array you read is in $ row
$ Row ['userid'] = "$ row [userid]";
Then foreach
------ Solution --------------------
Foreach ($ arr as $ v ){
Echo "'". $ v ['userid']. "'";
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.