How to operate on array elements with specific key names

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 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 ..


Reply to discussion (solution)

Isn't it the same? you just need to add a link to the output.

Isn't it the same? you just need to add a link to the output.

That is to say, I need to determine whether to add a link based on the key name.
The array extracted from the database may contain multiple rows and multiple fields in each row.
I only want to add hyperlinks to a field, while other fields are just plain text.
So I don't know how to determine whether to output a hyperlink in a loop based on the key name

You can paste your code to see how you write it now.

Foreach ($ arr as $ key => $ value ){
If ($ key = "userid "){
Echo "". $ key ."";
}
}

Your code has no syntax errors. can it not be displayed, or is it not what you need?

For example, if the array you read is in $ row
$ Row ['userid'] = "$ row [userid]";
Then foreach

foreach($arr as $v){    echo "'".$v['userid']."'";}

Well, what I want is the effect of the code provided on the fourth floor.

I will try some of them downstairs.

Thank you!

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.