This is the arrays in MYSQL.
Here is my PHP code for merging the array. Basically I want to validate whether the user entered number exists.
public function check_serial_from_exist(){
$serial = $this->input->post('serial_no_from');
$scope_id = $this->input->post('scope_id');
$client_id = $this->input->post('client_id');
$get_serials = $this->db->select('used_serials')->where('certification_scope',$scope_id,'clientid',$client_id)->get('tbllabels')->result_array();
$all_used_serials = array();
$status = 'true';
for($i=0;$i<count($get_serials);$i++){
$all_used_serials[] = json_decode($get_serials[$i]['used_serials']);
}
for($j=0;$j<count($all_used_serials);$j++){
if(in_array($serial,$all_used_serials[$j])){
$status = 'false';
}
else{
$status = 'true';
}
}
echo ''.$status;
}
When I print the array I got this:
Array ( [0] => Array ( [0] => 10 [1] => 11 [2] => 12 [3] => 13 [4] => 14 [5] => 15 [6] => 16 [7] => 17 [8] => 18 ) [1] => Array ( [0] => 20 [1] => 21 [2] => 22 [3] => 23 [4] => 24 [5] => 25 [6] => 26 [7] => 27 [8] => 28 [9] => 29 [10] => 30 ) [2] => Array ( [0] => 50 [1] => 51 [2] => 52 [3] => 53 [4] => 54 [5] => 55 [6] => 56 [7] => 57 [8] => 58 [9] => 59 [10] => 60 ) [3] => Array ( [0] => 70 [1] => 71 [2] => 72 [3] => 73 [4] => 74 [5] => 75 [6] => 76 [7] => 77 [8] => 78 [9] => 79 [10] => 80 ) [4] => Array ( [0] => 85 [1] => 86 [2] => 87 [3] => 88 [4] => 89 [5] => 90 ) )
Anyone help me to fix this? Thanks in advance.
My Answer:
PHP is a popular server-side scripting language that is used to create dynamic web pages. It is often used in conjunction with HTML to add functionality to websites, such as processing form data, interacting with databases, and generating dynamic content. PHP code is embedded within HTML documents and is executed on the server before the page is sent to the client's web browser.
Rate this post
4 of 5 based on 3280 votesComments