首页 \ 问答 \ 基于辅助数组集中的元素数量对数组进行排序,作为PHP中的值(Sort array based on the number of elements in the secondary array set as the value in PHP)

基于辅助数组集中的元素数量对数组进行排序,作为PHP中的值(Sort array based on the number of elements in the secondary array set as the value in PHP)

我给了一个填充的数组看起来像这样 -

$array = array(
   0 => array(2,3,4),
   1 => array(2,3,7,6,8),
   -- and so on  
 );

在PHP / PHP5.x中是否有简写来根据主数组中每个键的值中的元素数量来完成对这样一个数组的排序? 谢谢。


I gave an array populated to look like this -

$array = array(
   0 => array(2,3,4),
   1 => array(2,3,7,6,8),
   -- and so on  
 );

Is there a shorthand in PHP/PHP5.x to accomplish sorting of such an array based on the number of elements in the value to each key of the primary array? Thanks.


原文:https://stackoverflow.com/questions/21199927
更新时间:2024-03-10 09:03

最满意答案

C ++中的标识符名称规则是:

  1. 它不能以数字开头
  2. 可以由字母,数字,下划线,通用字符名称1实现定义的字符组成
  3. 不能是关键字

涵盖此C ++草案标准的部分是2.11 标识符 ,其中包括以下语法:

identifier:
  identifier-nondigit            <- Can only start with a non-digit
  identifier identifier-nondigit <- Next two rules allows for subsequent 
  identifier digit               <-  characters to be those outlined in 2 above
identifier-nondigit:
  nondigit                       <- a-z, A-Z and _ 
  universal-character-name
  other implementation-defined characters
[...]

2.12 关键词解释了保留用作关键字的所有标识符

最后,还保留下列名称:

  1. 包含双下划线__名称,或者在任何范围内以下划线开头,后面跟着大写字母(如_Apple
  2. 以全局名称空间中的下划线开头的名称(如全局名称空间中的_apple )将被保留。

标准草案涵盖的部分是17.6.4.3.2 。 我们可以找到一个理由,说明为什么这些是从国际标准编程语言理论C中保留的,它说:

[...]这为编写大量的幕后非外部宏和函数库提供了一个名称空间,以便图书馆正确地完成其工作[...]

C ++中,这也适用于名称修改,如本所示。


脚注

  • 1.允许通用字符

Annex E.1涵盖了允许的通用字符:

E.1允许字符的范围[charname.allowed]

00A8,00AA,00AD,

00AF,00B2-00B5,00B7-00BA,00BC-00BE,00C0-00D6,00D8-00F6,00F8-00FF

0100-167F,1681-180D,180F-1FFF 200B-200D,202A-202E,203F-2040,2054,

2060-206F 2070-218F,2460-24FF,2776-2793,2C00-2DFF,2E80-2FFF

3004-3007,3021-302F,3031-303F

3040-D7FF F900-FD3D,FD40-FDCF,

FDF0-FE44,FE47-FFFD

10000-1FFFD,20000-2FFFD,30000-3FFFD,40000-4FFFD,50000-5FFFD,60000-6FFFD,70000-7FFFD,80000-8FFFD,90000-9FFFD,A0000-AFFFD,B0000-BFFFD,C0000-CFFFD,D0000- DFFFD,E0000-EFFFD


Rules for identifier names in C++ are:

  1. It can not start with a number
  2. Can be composed of letters, numbers, underscore, universal character names1 and implementation defined characters
  3. Can not be a keyword.

The sections in the C++ draft standard that cover this are 2.11 Identifiers which includes the following grammar:

identifier:
  identifier-nondigit            <- Can only start with a non-digit
  identifier identifier-nondigit <- Next two rules allows for subsequent 
  identifier digit               <-  characters to be those outlined in 2 above
identifier-nondigit:
  nondigit                       <- a-z, A-Z and _ 
  universal-character-name
  other implementation-defined characters
[...]

and 2.12 Keywords explains all the identifier reserved for use as keywords.

Finally, the following names are also reserved:

  1. Names that contain a double underscore __, or start with either an underscore followed by an uppercase letter (like _Apple) in any scope,
  2. Names that start with an underscore in the global namespace (like _apple in the global namespace) are reserved.

The section that covers this in the draft standard is 17.6.4.3.2. We can find a rationale for why these are reserved from Rationale for International Standard—Programming Languages—C which says:

[...]This gives a name space for writing the numerous behind-the-scenes non-external macros and functions a library needs to do its job properly[...]

In C++ this also applies to name mangling as this example shows.


Footnotes

  • 1. Allowed universal characters

The universal characters that are allowed is covered in Annex E.1:

E.1 Ranges of characters allowed [charname.allowed]

00A8, 00AA, 00AD,

00AF, 00B2-00B5, 00B7-00BA, 00BC-00BE, 00C0-00D6, 00D8-00F6, 00F8-00FF

0100-167F, 1681-180D, 180F-1FFF 200B-200D, 202A-202E, 203F-2040, 2054,

2060-206F 2070-218F, 2460-24FF, 2776-2793, 2C00-2DFF, 2E80-2FFF

3004-3007, 3021-302F, 3031-303F

3040-D7FF F900-FD3D, FD40-FDCF,

FDF0-FE44, FE47-FFFD

10000-1FFFD, 20000-2FFFD, 30000-3FFFD, 40000-4FFFD, 50000-5FFFD, 60000-6FFFD, 70000-7FFFD, 80000-8FFFD, 90000-9FFFD, A0000-AFFFD, B0000-BFFFD, C0000-CFFFD, D0000-DFFFD, E0000-EFFFD

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。