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!