如何使用适当的格式创建唯一代码

时间:2014-12-09 08:25:42

标签: php

我想创建与我的唯一代码格式

的特定选定项目相关的唯一代码

FN1A,FN1B --------- FN1Z z循环再次启动后

FN2A,FN2B ----------- FN2Z等等

我在这里使用此代码

<?php

    for($row=1; $row<=22; $row++){
        echo "<tr>";
        for ($column='A'; $column!='AA'; $column++){ 
            echo "<td> $row $column </td>";
        }   
        echo "</tr>";
    }
?>

请帮助我们创建我在此

中提到的相同格式的独特示例代码

4 个答案:

答案 0 :(得分:3)

尝试PHP范围

<?php

        for($row=1; $row<=22; $row++){
            echo "<tr>";
            foreach (range('A', 'Z') as $char) { // Get A - Z as array 
              echo "FN{$row}{$char}";  //Concatenate as per your requirements 
             }
            echo "</tr>";
        }
    ?>

答案 1 :(得分:0)

  for($row=1; $row<=22; $row++){
    echo "<tr>";
    for ($column='A'; $column<='Z'; $column++){ 
        echo "<td> FN".$row . $column." </td>";
    }   
    echo "</tr>";
  }

答案 2 :(得分:0)

我认为你缺少的是php中的范围功能,访问http://php.net/manual/en/function.range.php获取详细信息,我将留下你建立的示例,问候。

<?php 

$array_alb = range('A', 'Z');
$array_num = range('1', '9');

echo '<pre>';
print_r($array_alb);
echo '</pre><pre>';
print_r($array_num);
echo '</pre>';

$preffix = 'FN';
$result  = array();

foreach ($array_num as $num) 
{
    foreach($array_alb as $letter)
    {
        $result[] = $preffix.$num.$letter;
    }
}

echo '<pre>';
print_r($result);
echo '<pre>';
?> 

Array
(
    [0] => FN1A
    [1] => FN1B
    [2] => FN1C
    [3] => FN1D
    [4] => FN1E
    [5] => FN1F
    [6] => FN1G
    [7] => FN1H
    [8] => FN1I
    [9] => FN1J
    [10] => FN1K
    [11] => FN1L
    [12] => FN1M
    [13] => FN1N
    [14] => FN1O
    [15] => FN1P
    [16] => FN1Q
    [17] => FN1R
    [18] => FN1S
    [19] => FN1T
    [20] => FN1U
    [21] => FN1V
    [22] => FN1W
    [23] => FN1X
    [24] => FN1Y
    [25] => FN1Z
    [26] => FN2A
    [27] => FN2B
    [28] => FN2C
    [29] => FN2D
    [30] => FN2E
    [31] => FN2F
    [32] => FN2G
    [33] => FN2H
    [34] => FN2I
    [35] => FN2J
    [36] => FN2K
    [37] => FN2L
    [38] => FN2M
    [39] => FN2N
    [40] => FN2O
    [41] => FN2P
    [42] => FN2Q
    [43] => FN2R
    [44] => FN2S
    [45] => FN2T
    [46] => FN2U
    [47] => FN2V
    [48] => FN2W
    [49] => FN2X
    [50] => FN2Y
    [51] => FN2Z
    [52] => FN3A
    [53] => FN3B
    [54] => FN3C
    [55] => FN3D
    [56] => FN3E
    [57] => FN3F
    [58] => FN3G
    [59] => FN3H
    [60] => FN3I
    [61] => FN3J
    [62] => FN3K
    [63] => FN3L
    [64] => FN3M
    [65] => FN3N
    [66] => FN3O
    [67] => FN3P
    [68] => FN3Q
    [69] => FN3R
    [70] => FN3S
    [71] => FN3T
    [72] => FN3U
    [73] => FN3V
    [74] => FN3W
    [75] => FN3X
    [76] => FN3Y
    [77] => FN3Z
    [78] => FN4A
    [79] => FN4B
    [80] => FN4C
    [81] => FN4D
    [82] => FN4E
    [83] => FN4F
    [84] => FN4G
    [85] => FN4H
    [86] => FN4I
    [87] => FN4J
    [88] => FN4K
    [89] => FN4L
    [90] => FN4M
    [91] => FN4N
    [92] => FN4O
    [93] => FN4P
    [94] => FN4Q
    [95] => FN4R
    [96] => FN4S
    [97] => FN4T
    [98] => FN4U
    [99] => FN4V
    [100] => FN4W
    [101] => FN4X
    [102] => FN4Y
    [103] => FN4Z
    [104] => FN5A
    [105] => FN5B
    [106] => FN5C
    [107] => FN5D
    [108] => FN5E
    [109] => FN5F
    [110] => FN5G
    [111] => FN5H
    [112] => FN5I
    [113] => FN5J
    [114] => FN5K
    [115] => FN5L
    [116] => FN5M
    [117] => FN5N
    [118] => FN5O
    [119] => FN5P
    [120] => FN5Q
    [121] => FN5R
    [122] => FN5S
    [123] => FN5T
    [124] => FN5U
    [125] => FN5V
    [126] => FN5W
    [127] => FN5X
    [128] => FN5Y
    [129] => FN5Z
    [130] => FN6A
    [131] => FN6B
    [132] => FN6C
    [133] => FN6D
    [134] => FN6E
    [135] => FN6F
    [136] => FN6G
    [137] => FN6H
    [138] => FN6I
    [139] => FN6J
    [140] => FN6K
    [141] => FN6L
    [142] => FN6M
    [143] => FN6N
    [144] => FN6O
    [145] => FN6P
    [146] => FN6Q
    [147] => FN6R
    [148] => FN6S
    [149] => FN6T
    [150] => FN6U
    [151] => FN6V
    [152] => FN6W
    [153] => FN6X
    [154] => FN6Y
    [155] => FN6Z
    [156] => FN7A
    [157] => FN7B
    [158] => FN7C
    [159] => FN7D
    [160] => FN7E
    [161] => FN7F
    [162] => FN7G
    [163] => FN7H
    [164] => FN7I
    [165] => FN7J
    [166] => FN7K
    [167] => FN7L
    [168] => FN7M
    [169] => FN7N
    [170] => FN7O
    [171] => FN7P
    [172] => FN7Q
    [173] => FN7R
    [174] => FN7S
    [175] => FN7T
    [176] => FN7U
    [177] => FN7V
    [178] => FN7W
    [179] => FN7X
    [180] => FN7Y
    [181] => FN7Z
    [182] => FN8A
    [183] => FN8B
    [184] => FN8C
    [185] => FN8D
    [186] => FN8E
    [187] => FN8F
    [188] => FN8G
    [189] => FN8H
    [190] => FN8I
    [191] => FN8J
    [192] => FN8K
    [193] => FN8L
    [194] => FN8M
    [195] => FN8N
    [196] => FN8O
    [197] => FN8P
    [198] => FN8Q
    [199] => FN8R
    [200] => FN8S
    [201] => FN8T
    [202] => FN8U
    [203] => FN8V
    [204] => FN8W
    [205] => FN8X
    [206] => FN8Y
    [207] => FN8Z
    [208] => FN9A
    [209] => FN9B
    [210] => FN9C
    [211] => FN9D
    [212] => FN9E
    [213] => FN9F
    [214] => FN9G
    [215] => FN9H
    [216] => FN9I
    [217] => FN9J
    [218] => FN9K
    [219] => FN9L
    [220] => FN9M
    [221] => FN9N
    [222] => FN9O
    [223] => FN9P
    [224] => FN9Q
    [225] => FN9R
    [226] => FN9S
    [227] => FN9T
    [228] => FN9U
    [229] => FN9V
    [230] => FN9W
    [231] => FN9X
    [232] => FN9Y
    [233] => FN9Z
)

答案 3 :(得分:0)

我知道你用我的逻辑连接的连接人员,但我有特定样本的表单我从下拉列表中选择一个独特的代码genrate并插入数据库