Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use array_column () of PHP

Shulou Source: shulou.com Published: 2022-06-03 05:42:22 09月17日 Update

This article mainly explains "how to use PHP's array_column ()". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use PHP's array_column ()".

1, convert an int class list to a comma concatenated string

Ints = [str (int) for int in ints] str_of_ints = "," .join (string_ints)

2. Implement the array_column () method of PHP

A = [{"id": 1, "name": "Aaron"}, {"id": 2, "name": "Bob"}] dict (list (map (lambda x: [x ["id"], x [name "], a) / / id= > name dictionary {1: 'Aaron', 2:' Bob'} dict (map (lambda x: [x [id"], x], a)) / / id= > {"id": X Dictionary of "name": "xxx"} {1: {'id': 1,' name': 'Aaron'}, 2: {' id': 2, 'name':' Bob'}}

The division in 3.x and 2.7 is not the same.

A = 23x10 / / the result in 3.x is 2.3a = round (float (23) / 10,1) / / the method of obtaining floating point quotient (keep 1 decimal place) in 2.7.Thank you for your reading. this is the content of "how to use PHP's array_column ()" after the study of this article. I believe you have a deeper understanding of how to use PHP's array_column (), and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Learning content dictionary method results characters strings decimals that is ideas situations articles more floating points knowledge knowledge points articles followed commas questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker Apple Microsoft MySQL