如何使用 php 数组将条形码详细信息发送到数据库
How to send barcode details to database using a php array
我想使用 PHP 数组将条形码详细信息发送到数据库,并希望根据条形码详细信息在数据库中创建表。例如;
条码编号:D2D6000001
这里第1个D表示产品类型,2个表示生产线,第2个D表示月份,6个表示年份,后6位数字表示产品编号
我想使用 PHP 数组将每一个发送到数据库中的单独表中。有人可以帮我解决这个问题吗?
试试下面的脚本:
<?php
$ReciveBarcode = "D2D6000001";
$GETBARCODE = str_split($ReciveBarcode,5);
$SepratedDetails['productType'] = $GETBARCODE[0][0];
$SepratedDetails['productionLine'] = $GETBARCODE[0][1];
$SepratedDetails['month'] = $GETBARCODE[0][2];
$SepratedDetails['year'] = $GETBARCODE[0][3];
$SepratedDetails['productNumber'] = $GETBARCODE[1];
echo "<pre>";print_r($SepratedDetails);
?>
输出:
Array
(
[productType] => D
[productionLine] => 2
[month] => D
[year] => 6
[productNumber] => 00001
)
Using str_split("D2D6000001")
to split the value to array.
You get result some thing like Array ( [0] => D[1] => 2 [2] => D [3] => 6 [4] => 0 )
.
use substr("D2D6000001",-6)
to get six digit value.
我想使用 PHP 数组将条形码详细信息发送到数据库,并希望根据条形码详细信息在数据库中创建表。例如;
条码编号:D2D6000001
这里第1个D表示产品类型,2个表示生产线,第2个D表示月份,6个表示年份,后6位数字表示产品编号
我想使用 PHP 数组将每一个发送到数据库中的单独表中。有人可以帮我解决这个问题吗?
试试下面的脚本:
<?php
$ReciveBarcode = "D2D6000001";
$GETBARCODE = str_split($ReciveBarcode,5);
$SepratedDetails['productType'] = $GETBARCODE[0][0];
$SepratedDetails['productionLine'] = $GETBARCODE[0][1];
$SepratedDetails['month'] = $GETBARCODE[0][2];
$SepratedDetails['year'] = $GETBARCODE[0][3];
$SepratedDetails['productNumber'] = $GETBARCODE[1];
echo "<pre>";print_r($SepratedDetails);
?>
输出:
Array
(
[productType] => D
[productionLine] => 2
[month] => D
[year] => 6
[productNumber] => 00001
)
Using
str_split("D2D6000001")
to split the value to array. You get result some thing likeArray ( [0] => D[1] => 2 [2] => D [3] => 6 [4] => 0 )
. usesubstr("D2D6000001",-6)
to get six digit value.