Skip to content
Advertisement

Getting a single attribute from a php array

I have a php array that I’ve filtered based on the datasetID the $result is therefore a single record.

I would like to echo a single attribute i.e. ["genus"] I’ve tried echo $result[0]['genus']; but that wont work. Any tips? I hope this is a simple one?

JavaScript

Advertisement

Answer

If you are filtering the datasetId by array_filter utility. Then you can do one thing

JavaScript

This would return you a new array with index starting from 0. After that you can try

JavaScript

Hope this would help.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement