这是我的$ array的结果:
Array ( [row] => Array ( [Field] => product_id [Type] => int(11) [Null] => NO [Key] => PRI [Default] => [Extra] => auto_increment ) [rows] => Array ( [0] => Array ( [Field] => product_id [Type] => int(11) [Null] => NO [Key] => PRI [Default] => [Extra] => auto_increment ) [1] => Array ( [Field] => model [Type] => varchar(64) [Null] => NO [Key] => [Default] => [Extra] => ) [2] => Array ( [Field] => sku [Type] => varchar(64) [Null] => NO [Key] => [Default] => [Extra] => ) [3] => Array ( [Field] => upc [Type] => varchar(12) [Null] => NO [Key] => [Default] => [Extra] => ) [4] => Array ( [Field] => ean [Type] => varchar(14) [Null] => NO [Key] => [Default] => [Extra] => ) [5] => Array ( [Field] => jan [Type] => varchar(13) [Null] => NO [Key] => [Default] => [Extra] => ) [6] => Array ( [Field] => isbn [Type] => varchar(13) [Null] => NO [Key] => [Default] => [Extra] => ) [7] => Array ( [Field] => mpn [Type] => varchar(64) [Null] => NO [Key] => [Default] => [Extra] => ) [8] => Array ( [Field] => location [Type] => varchar(128) [Null] => NO [Key] => [Default] => [Extra] => ) [9] => Array ( [Field] => quantity [Type] => int(4) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [10] => Array ( [Field] => stock_status_id [Type] => int(11) [Null] => NO [Key] => [Default] => [Extra] => ) [11] => Array ( [Field] => image [Type] => varchar(255) [Null] => YES [Key] => [Default] => [Extra] => ) [12] => Array ( [Field] => manufacturer_id [Type] => int(11) [Null] => NO [Key] => [Default] => [Extra] => ) [13] => Array ( [Field] => shipping [Type] => tinyint(1) [Null] => NO [Key] => [Default] => 1 [Extra] => ) [14] => Array ( [Field] => price [Type] => decimal(15,4) [Null] => NO [Key] => [Default] => 0.0000 [Extra] => ) [15] => Array ( [Field] => points [Type] => int(8) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [16] => Array ( [Field] => tax_class_id [Type] => int(11) [Null] => NO [Key] => [Default] => [Extra] => ) [17] => Array ( [Field] => date_available [Type] => date [Null] => NO [Key] => [Default] => [Extra] => ) [18] => Array ( [Field] => weight [Type] => decimal(15,8) [Null] => NO [Key] => [Default] => 0.00000000 [Extra] => ) [19] => Array ( [Field] => weight_class_id [Type] => int(11) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [20] => Array ( [Field] => length [Type] => decimal(15,8) [Null] => NO [Key] => [Default] => 0.00000000 [Extra] => ) [21] => Array ( [Field] => width [Type] => decimal(15,8) [Null] => NO [Key] => [Default] => 0.00000000 [Extra] => ) [22] => Array ( [Field] => height [Type] => decimal(15,8) [Null] => NO [Key] => [Default] => 0.00000000 [Extra] => ) [23] => Array ( [Field] => length_class_id [Type] => int(11) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [24] => Array ( [Field] => subtract [Type] => tinyint(1) [Null] => NO [Key] => [Default] => 1 [Extra] => ) [25] => Array ( [Field] => minimum [Type] => int(11) [Null] => NO [Key] => [Default] => 1 [Extra] => ) [26] => Array ( [Field] => sort_order [Type] => int(11) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [27] => Array ( [Field] => status [Type] => tinyint(1) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [28] => Array ( [Field] => serial [Type] => tinyint(1) [Null] => NO [Key] => [Default] => 0 [Extra] => ) [29] => Array ( [Field] => serialn [Type] => varchar(64) [Null] => NO [Key] => [Default] => [Extra] => ) [30] => Array ( [Field] => date_added [Type] => datetime [Null] => NO [Key] => [Default] => 0000-00-00 00:00:00 [Extra] => ) [31] => Array ( [Field] => date_modified [Type] => datetime [Null] => NO [Key] => [Default] => 0000-00-00 00:00:00 [Extra] => ) [32] => Array ( [Field] => viewed [Type] => int(5) [Null] => NO [Key] => [Default] => 0 [Extra] => ) ) [num_rows] => 33 )
如果找到“串行”,如果找不到,那么如何搜索“串口”,如果找不到,那么就做其他事情?
我试过这个
if(array_search('serial',$array)) { echo "hello"; } else { echo "heheheh";}
它只是没有做我想做的事情?
答案 0 :(得分:2)
试试这个
foreach( $array['rows'] as $array1 ){
if( array_search('serial', $array) ){
do something here
}
}