i I have a problem to print array .I received this array of web services by nusoap
How can I display the values of this multidimensional array. I worked with foreach, I could not do it., Please explain with an example. Thanks
my array:
Array ( [Result] => Array ( [Root] => Array ( [row] => Array ( [0] => Array ( [!R] => 0 [!C1] => 300064 [!C2] => name1 [!C3] => 1287744941 [!C4] => 798 [!C5] => 1338/06/29 [!C6] => [!C7] =>name2 [!C8] =>name2 91 ) [1] => Array ( [!R] => 19 [!C1] => 300064 [!C2] => name1 [!C3] => 1287744941 [!C4] => 798 [!C5] => 1338/06/29 [!C6] => [!C7] =>name2 [!C8] =>name2 92 ) [2] => Array ( [!R] => 38 [!C1] => 300064 [!C2] => name1 [!C3] => 1287744941 [!C4] => 798 [!C5] => 1338/06/29 [!C6] => [!C7] =>name2 [!C8] =>name2 93 ) [3] => Array ( [!R] => 57 [!C1] => 300064 [!C2] => name1 [!C3] => 1287744941 [!C4] => 798 [!C5] => 1338/06/29 [!C6] => [!C7] => name3 [!C8] => name3 ) ) ) ) )
Related
Houston I have a Problem. I have this preg_match_all the response is many array with duplicate numbers (the original data has these duplicates). I need to eliminate duplicate numbers and transfer to one variable. I Try with array_unique() and array_merge(). Thx for your help.
preg_match_all('~x">([^"]*)<\/h4>|[0-9]{5}~',$preg_data,$item, PREG_SET_ORDER);
Output:
Array ( )
Array ([0] => x"> 13:30 - Denver</h4> [1] => 13:30 - Denver)
Array ( )
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69275))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69275))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69275))
Array ()
Array ([0] => x"> 16:00 - Miami</h4>[1] => 16:00 - Miami)
Array ()
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69280))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69280))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69280))
if (#preg_match_all('/([0-9]{5})/',$item[0],$match, PREG_SET_ORDER)); {
print_r($match);}
Array ( )
Array ( [0] => Array ( [0] => 69268 [1] => 69268 ))
Array ( [0] => Array ( [0] => 69268 [1] => 69268 ))
Array ( )
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( )
Array ( )
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( )
Array ( )
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( )
I use this combinations
preg_match_all('~x">([^"]*)<\/h4>|[0-9]{5}~',$preg_data,$data_mach);
$data_clean= array_values(array_filter(array_unique($data_mach[0])));
preg_mach to extrac data
array_unique to eliminate duplicates
array_filter to eliminate blank
array_values to work only numbers.
Done.
my controller is : **
public function getdatewiseOrder()
{
$cid = $this->input->post('cid');
$startdate = strtotime($this->input->post('start_date'));
$enddate = strtotime($this->input->post('end_date'));
$order = $this->model_reports->getdatewiseOrder($cid, $startdate, $enddate);
$x = 0;
foreach ($order as $key => $value) {
$item[$x] = $this->model_reports->getorderItem($value['id']);
$x = $x + 1;
}
$this->data['order'] = $order;
$this->data['item'] = $item;
$this->render_template('reports/leser_report', $this->data);
}
for check : after print_r of item variable i get data in this format:
Array (
[0] => Array (
[0] => Array (
[id] => 188
[order_id] => 93
[product_name] => 2
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 1
[qtypcs] => 2
[unit] =>
[rate] => 234
[amount] => 234.00
[tax_id] =>
[timestamp] => 2018-10-30 12:51:10
)
)
[1] => Array (
[0] => Array (
[id] => 191
[order_id] => 96
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 100
[amount] => 500.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:41
)
[1] => Array (
[id] => 192
[order_id] => 96
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 5
[qtypcs] => 5
[unit] =>
[rate] => 90
[amount] => 450.00
[tax_id] =>
[timestamp] => 2018-11-15 09:49:43
)
)
[2] => Array (
[0] => Array (
[id] => 206
[order_id] => 105
[product_name] => Small
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 2
[qtypcs] => 50
[unit] =>
[rate] => 100
[amount] => 200.00
[tax_id] =>
[timestamp] => 2018-11-15 13:38:47
)
)
[3] => Array (
[0] => Array (
[id] => 207
[order_id] => 106
[product_name] => Medium
[barcode_nos] =>
[barcode_no] =>
[qtykg] => 50
[qtypcs] => 100
[unit] =>
[rate] => 15
[amount] => 750.00
[tax_id] =>
[timestamp] => 2018-11-15 13:40:12
)
)
)
I have two tables order and order_item and i am fetch data from both
for fetching data from order table i use
$order = $this->model_reports->getdatewiseOrder($cid, $startdate,
$enddate);
for fetching data from order_item i am using
$item[$x] = $this->model_reports->getorderItem($value['id']);
inside foreach loop
I want output in this format
enter image description here
Have look Please i have 2 arrays array1 and array2 i want to compare these arrays and need the array back which is not exist in array2.
I really to resolve this issue i am working on app.
So kindly help me to resolve this issue
Thanks in Advance.
Here is array 1
Array
(
[0] => Array
(
[image_id] => 4
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
[1] => Array
(
[image_id] => 3
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
[2] => Array
(
[image_id] => 2
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
[3] => Array
(
[image_id] => 1
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
)
Here is array2
Array
(
[0] => Array
(
[image_id] => 1
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
[1] => Array
(
[image_id] => 4
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
)
I need result like this
Result Array
Array(
[0] => Array
(
[image_id] => 3
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
[1] => Array
(
[image_id] => 2
[user_id] => 2
[user_type] => user
[canvas_id] => 1
[canvas_mac] => 123.234.232.121
)
)
Please try array_udiff (http://php.net/array_udiff). Does it meet your requirements?
The print_r returns the following value:
[cobrancas] => Array
(
[0] => stdClass Object
(
[id] => 749205
[nossonumero] => 3189028
[dataemissao] => 1395284400
[datavencimento] => 1395370800
[datapagamento] => 1395284400
[dias_vencidos] => 788
[mora] => 0.23225806451613
[multa] => 1.8
[valor] => 90.00
[valorpago] => 88.57
[valordesconto] => 0.00
[jurosmora] => 0.00
[banco] => 33
[agencia] => 1525
[dac_agencia] => 0
[conta] => 013000045
[dac_conta] => 2
[carteira] => 201
[nome_empresa] => STOCK MIDIA INF. LTDA
[cod_cedente] => 1640348
)
But as I know it gives me values of up to [ 50 ] up. How do I know the print me just [VALOR ] above 100.00 ???
$Arr = count($cliente->cobrancas);
Presently m working with CakePhp..i got some problem with combining two array and prepare for a json encoded array.. i used array_merge() property but its not working.. how can i encoded both of these two array..
M doing like this :
return json_encode(array_merge ($product_list,$price_list));
i have two php array as follows :
array 1:
Array
(
[0] => Array
(
[PriceList] => Array
(
[price_id] => 2
[price_name] => abc
[date_time] => 2015-07-06 16:22:56
[dealer_type] => Dealer
[purpose] => dealer
[status] => ACTIVE
)
)
[1] => Array
(
[PriceList] => Array
(
[price_id] => 3
[price_name] => xyz
[date_time] => 2015-07-06 16:22:56
[dealer_type] => Dealer
[purpose] => dealer
[status] => ACTIVE
)
)
)
array 2:
Array
(
[0] => Array
(
[Product] => Array
(
[cat_id] => 1
[subcat_id] => 3
[brand_id] => 1
[p_code] => PP12567
[name] => akai
[model_no] =>
[specification] => color tv
[color] =>
[quality] =>
[size] =>
[p_unavail] => 1
[demo_avail] => 0
[brochure] =>
[status] => active
)
[ProductPrice] => Array
(
[id] => 154
[p_code] => PP12567
[price_id] => 1
[quantity] => 233
[purchase_price] => 344.00
[selling_price] => 44.00
[discount_price] => 33.00
[tax] => 5.00
[datetime] => 2015-07-23 15:47:11
)
[ProductSubCategory] => Array
(
[subcat_id] => 3
[cat_id] => 1
[subcat_name] => samsung
[status] => active
)
[ProductCategory] => Array
(
[cat_id] => 1
[cat_name] => Electronics
[cat_type] => Product
[status] => active
)
)
[1] => Array
(
[Product] => Array
(
[cat_id] => 1
[subcat_id] => 4
[brand_id] => 1
[p_code] => PBC-676767
[name] => music
[model_no] => 33
[specification] =>
[color] =>
[quality] =>
[size] =>
[p_unavail] => 0
[demo_avail] => 0
[brochure] =>
[status] => active
)
[ProductPrice] => Array
(
[id] => 156
[p_code] => PBC-676767
[price_id] => 1
[quantity] => 767
[purchase_price] => 54.00
[selling_price] => 55.00
[discount_price] => 22.00
[tax] => 3.00
[datetime] => 2015-07-23 15:47:11
)
[ProductSubCategory] => Array
(
[subcat_id] => 4
[cat_id] => 1
[subcat_name] => sony
[status] => active
)
[ProductCategory] => Array
(
[cat_id] => 1
[cat_name] => Electronics
[cat_type] => Product
[status] => active
)
)
)
how to combine these two array into one and encoded into a json array..
You have to use array_merge but not directly on array1 and array2:
$toEncodeArray = [array_merge ($array1[0], $array2[0])] ;
If you only want the associative array (without the wrapping array), simply do:
$toEncodeArray = array_merge ($array1[0], $array2[0]) ;