基于辅助数组集中的元素数量对数组进行排序,作为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
最满意答案
C ++中的标识符名称规则是:
- 它不能以数字开头
- 可以由字母,数字,下划线,通用字符名称1和实现定义的字符组成
- 不能是关键字 。
涵盖此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
关键词解释了保留用作关键字的所有标识符 。最后,还保留下列名称:
- 包含双下划线
__
名称,或者在任何范围内以下划线开头,后面跟着大写字母(如_Apple
)- 以全局名称空间中的下划线开头的名称(如全局名称空间中的
_apple
)将被保留。本标准草案涵盖的部分是
17.6.4.3.2
。 我们可以找到一个理由,说明为什么这些是从国际标准编程语言理论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:
- It can not start with a number
- Can be composed of letters, numbers, underscore, universal character names1 and implementation defined characters
- 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:
- Names that contain a double underscore
__
, or start with either an underscore followed by an uppercase letter (like_Apple
) in any scope,- 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
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
C ++中的标识符名称规则是: 它不能以数字开头 可以由字母,数字,下划线,通用字符名称1和实现定义的字符组成 不能是关键字 。 涵盖此C ++草案标准的部分是2.11 标识符 ,其中包括以下语法: identifier: identifier-nondigit <- Can only start with a non-digit identifier identifier-nondigit <- Next two rules allows for subsequent ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
MySQL中的6位数字列(6 digit numeric column in MySQL)[2023-03-21]
使用MEDIUMINT数据类型,或更确切地说,MEDIUMINT(6): 一个中等大小的整数。 符号范围是-8388608到8388607.无符号范围是0到16777215。 当您打算将它用作ID列时,您很可能希望将其设为UNSIGNED NOT NULL auto_increment 。 Use the MEDIUMINT data type, or more exact, MEDIUMINT(6): A medium-sized integer. The signed range is -8388608 ... -
从r中的数字中提取数字(Extract digit from numeric in r)[2023-09-10]
会有很多方法,但这里有一个: (x %% 1)*10 # [1] 0 1 2 这假设小数点后只有一位数。 如果不是这样的话: floor((x %% 1)*10) There'll be a bunch of ways, but here's one: (x %% 1)*10 # [1] 0 1 2 This assumes there's only ever one digit after the decimal place. If that's not the case: floor((x %% ... -
您可以通过用[]括起来来转义表的名称: MySQLCommand.CommandText = "CREATE TABLE ["+textBox1.Text+"] (Col1 int, Col2 varchar(50), Col money)"; // Here ---------------------------------^-----------------^ You can escape the table's name by enclosing it with []: MySQLCommand.C ...
-
您可以在过滤后按初始字符分组,并将数据放入Map
: Map digCount = Files .lines(Paths.get("/path/to/file/text.txt")) .filter(Pattern.compile("\\d+").asPredicate()) .collect(Collectors.groupingBy(s -> s.charAt(0), Collectors.summing ... -
解决方案是: def digit_leading_lines(text): lines = text.splitlines() count = 0 for line in lines: if line and line[0].isdigit(): count += 1 return count Solution is: def digit_leading_lines(text): lines = text.splitlines ...
-
假设它是以毫秒为单位的UNIX时间 ,请尝试以下操作: DATEADD(SECOND, START_DATE/1000 ,'1970/1/1') 对于帖子中的数字,SQL-2008返回2011-08-29 16:59:42.000 Assuming it's UNIX time in milliseconds, try this: DATEADD(SECOND, START_DATE/1000 ,'1970/1/1') For the number from your post, SQL-2008 re ...
-
在HTML5中,CSS类名可以包含任何字符(并以其开头)。 但是,为了在CSS文件(或JavaScript函数)中定位花哨的CSS类名, 您需要转义它们 。 li.max-panel-size.\31 200mm-x-4700mm { background: #F00; } li.max-panel-size.\31 111mm-x-1111mm { background: #0F0; } li.max-panel-size.\39 999mm-x-9999mm { backgro ...