【发布时间】:2011-09-11 19:55:07
【问题描述】:
数组 $A 的所有值都是相同长度的字符串。
$A = Array
(
[0] => 03
[1] => 04
[2] => 05
[3] => 06
// [4] => 07 // "07" before "04" position
[4] => 04
[5] => 05
[6] => 06
// [8] => 07 // "07" before "08" position
[7] => 08
[8] => 03
[9] => 04
[10] => 05
[11] => 06
[12] => 07 // it is existing
[13] => 08
) ;
如果it is not existing 在“04”或“08”位置之前,我想插入“07”元素。从位置1开始
所以改了之后就可以了
$A = Array
(
[0] => 03
[1] => 04
[2] => 05
[3] => 06
[4] => 07 // just appended
[5] => 04
[6] => 05
[7] => 06
[8] => 07 // just append
[9] => 08
[10] => 03
[11] => 04
[12] => 05
[13] => 06
[14] => 07
[15] => 08
) ;
有人知道怎么做吗,请帮帮我?
【问题讨论】:
-
"append" 表示在末尾插入。你说的是更一般的插入。
-
@Tomalak 我确实相信他在更广泛地谈论家庭作业......
-
@newbie 你能解释一下为什么(在我们的预期结果中)07 只是有时在 04 之前被注入,而不是总是?