我需要減少這些數字的數量並以更簡潔的方式呈現它們,而不是用相同的「前綴」或「根」來呈現多行數字。例如:使用數組中的數據形成一個新的字符串PHP
如果我有一個這樣的陣列,以數字的幾串(OBS:只有數字和數組已經排序):
$array = array(
"12345647",
"12345648",
"12345649",
"12345657",
"12345658",
"12345659",
);
字符串:123456是所有元素相同數組,所以它將是數字的根或前綴。根據上述陣列我會得到這樣的結果:
//The numbers in brackets represent the sequence of the following numbers,
//instead of showing the rows, I present all the above numbers in just one row:
$stringFormed = "123456[4-5][7-9]";
又如:
$array2 = array(
"1234",
"1235",
"1236",
"1247",
"2310",
"2311",
);
從第二陣列,我應該得到這樣的結果:
$stringFormed1 = "123[4-7]";
$stringFormed2 = "1247";
$stringFormed3 = "231[0-1]";
有什麼想法?
[X-Y]是x是少,y爲的是什麼?如果有些數字不存在會怎麼樣? – 2012-07-23 09:34:49
請詳細說明您的問題。 – 2012-07-23 09:36:37
問題確實不是建設性的 – diEcho 2012-07-23 09:37:07