hello i have this type of array,
Array
(
[1] => Array
(
[0] => FGC00092
[splcode] => FGC00092
[1] => 2016-05-02,2016-05-09
[tran_date] => 2016-05-02,2016-05-09
[2] => 3,40
[unit] => 3,40
[3] => 300,320
[value] => 300,320
)
[2] => Array
(
[0] => FGC00085
[splcode] => FGC00085
[1] => 2016-05-06
[tran_date] => 2016-05-06
[2] => 2
[unit] => 2
[3] => 400
[value] => 400
)
[3] => Array
(
[0] => FGC00099
[splcode] => FGC00099
[1] => 2016-05-06
[tran_date] => 2016-05-06
[2] => 3
[unit] => 3
[3] => 600
[value] => 600
)
[4] => Array
(
[0] => FGC00092
[splcode] => FGC00092
[1] => 2016-05-09
[tran_date] => 2016-05-09
[2] => 40
[unit] => 40
[3] => 320
[value] => 320
)
[5] => Array
(
[0] => FGC00115
[splcode] => FGC00115
[1] => 2016-05-10
[tran_date] => 2016-05-10
[2] => 476
[unit] => 476
[3] => 3808
[value] => 3808
)
[6] => Array
(
[0] => FGC00062
[splcode] => FGC00062
[1] => 2016-05-25
[tran_date] => 2016-05-25
[2] => 10
[unit] => 10
[3] => 80
[value] => 80
)
[7] => Array
(
[0] => FGC00059
[splcode] => FGC00059
[1] => 2016-05-30
[tran_date] => 2016-05-30
[2] => 50
[unit] => 50
[3] => 400
[value] => 400
)
[8] => Array
(
[0] => FGC00117
[splcode] => FGC00117
[1] => 2016-05-31
[tran_date] => 2016-05-31
[2] => 50
[unit] => 50
[3] => 400
[value] => 400
)
)
i want to combine the them which have same ID. like for FGC00092, array structure must be,
Array
(
[1] => Array
(
[0] => FGC00092
[splcode] => FGC00092
[1] => 2016-05-02
[tran_date] => 2016-05-02
[2] => 3
[unit] => 3
[3] => 300
[value] => 300
)
[2] => Array
(
[0] => FGC00085
[splcode] => FGC00085
[1] => 2016-05-06
[tran_date] => 2016-05-06
[2] => 2
[unit] => 2
[3] => 400
[value] => 400
)
[3] => Array
(
[0] => FGC00099
[splcode] => FGC00099
[1] => 2016-05-06
[tran_date] => 2016-05-06
[2] => 3
[unit] => 3
[3] => 600
[value] => 600
)
[4] => Array
(
[0] => FGC00115
[splcode] => FGC00115
[1] => 2016-05-10
[tran_date] => 2016-05-10
[2] => 476
[unit] => 476
[3] => 3808
[value] => 3808
)
[5] => Array
(
[0] => FGC00062
[splcode] => FGC00062
[1] => 2016-05-25
[tran_date] => 2016-05-25
[2] => 10
[unit] => 10
[3] => 80
[value] => 80
)
[6] => Array
(
[0] => FGC00059
[splcode] => FGC00059
[1] => 2016-05-30
[tran_date] => 2016-05-30
[2] => 50
[unit] => 50
[3] => 400
[value] => 400
)
[7] => Array
(
[0] => FGC00117
[splcode] => FGC00117
[1] => 2016-05-31
[tran_date] => 2016-05-31
[2] => 50
[unit] => 50
[3] => 400
[value] => 400
)
)
You can use foreach and in_array to solve your issue as below.
$tempArray = $outArray = array();
$count = 1;
foreach($yourArray as $aKey=>$aVal){
if (in_array($aVal['splcode'], $aVal)){
//do something
continue; // it will skip the current loop if the condition satisfies
}
$outArray[$count] = $aVal;
$tempArray[] = $aVal['splcode'];
$count++;
}
//You will get the result in the variable $outArray
unset($tempArray); // clear the temp array
The array_unique function will do this for you. You just needed to add the SORT_REGULAR flag:
$items_thread = array_unique($items_thread, SORT_REGULAR);
Related
How can I get the specific item from the following array. I'd like to get the close values.
What should I do in this case?
$data = json_decode(file_get_contents($req_url),true);
// print_r($data); //give the following array;
// Array ( [chart] => Array ( [result] => Array ( [0] => Array ( [meta] => Array ( [currency] => USD [symbol] => SEAS [exchangeName] => NYQ [instrumentType] => EQUITY [firstTradeDate] => 1366378200 [regularMarketTime] => 1588622401 [gmtoffset] => -14400 [timezone] => EDT [exchangeTimezoneName] => America/New_York [regularMarketPrice] => 14.55 [chartPreviousClose] => 14.11 [previousClose] => 14.11 [scale] => 3 [priceHint] => 2 [currentTradingPeriod] => Array ( [pre] => Array ( [timezone] => EDT [end] => 1588599000 [start] => 1588579200 [gmtoffset] => -14400 ) [regular] => Array ( [timezone] => EDT [end] => 1588622400 [start] => 1588599000 [gmtoffset] => -14400 ) [post] => Array ( [timezone] => EDT [end] => 1588636800 [start] => 1588622400 [gmtoffset] => -14400 ) ) [tradingPeriods] => Array ( [0] => Array ( [0] => Array ( [timezone] => EDT [end] => 1588622400 [start] => 1588599000 [gmtoffset] => -14400 ) ) ) [dataGranularity] => 5m [range] => 1d [validRanges] => Array ( [0] => 1d [1] => 5d [2] => 1mo [3] => 3mo [4] => 6mo [5] => 1y [6] => 2y [7] => 5y [8] => 10y [9] => ytd [10] => max ) ) [timestamp] => Array ( [0] => 1588599000 [1] => 1588599300 [2] => 1588599600 [3] => 1588599900 [4] => 1588600200 [5] => 1588600500 ) [indicators] => Array ( [quote] => Array ( [0] => Array ( [open] => Array ( [0] => 13.3599996567 [1] => 13.8599996567 [2] => 13.720000267 [3] => 13.8800001144 [4] => 14.0349998474 [5] => 14.051199913 ) [close] => Array ( [0] => 13.9499998093 [1] => 13.7299995422 [2] => 13.8400001526 [3] => 14.0450000763 [4] => 14.0600004196 [5] => 14.1899995804 ) [high] => Array ( [0] => 14 [1] => 13.8599996567 [2] => 13.9399995804 [3] => 14.0900001526 [4] => 14.1000003815 [5] => 14.2600002289 ) [low] => Array ( [0] => 13.1099996567 [1] => 13.5900001526 [2] => 13.720000267 [3] => 13.8699998856 [4] => 13.8509998322 [5] => 14 ) [volume] => Array ( [0] => 124733 [1] => 49489 [2] => 51657 [3] => 48362 [4] => 34055 [5] => 36566 ) ) ) ) ) ) [error] => ) );
$close= $data['chart']['result']['indicators']['close'] ;
echo $close;
For your Array:
Array ( [chart] =>
Array ( [result] =>
Array ( [0] =>
Array ( [meta] =>
Array ( [currency] => USD [symbol] => SEAS [exchangeName] => NYQ [instrumentType] => EQUITY [firstTradeDate] => 1366378200 [regularMarketTime] => 1588622401 [gmtoffset] => -14400 [timezone] => EDT [exchangeTimezoneName] => America/New_York [regularMarketPrice] => 14.55 [chartPreviousClose] => 14.11 [previousClose] => 14.11 [scale] => 3 [priceHint] => 2 [currentTradingPeriod] =>
Array ( [pre] =>
Array ( [timezone] => EDT [end] => 1588599000 [start] => 1588579200 [gmtoffset] => -14400 ) [regular] =>
Array ( [timezone] => EDT [end] => 1588622400 [start] => 1588599000 [gmtoffset] => -14400 ) [post] =>
Array ( [timezone] => EDT [end] => 1588636800 [start] => 1588622400 [gmtoffset] => -14400 ) ) [tradingPeriods] =>
Array ( [0] =>
Array ( [0] =>
Array ( [timezone] => EDT [end] => 1588622400 [start] => 1588599000 [gmtoffset] => -14400 ) ) ) [dataGranularity] => 5m [range] => 1d [validRanges] =>
Array ( [0] => 1d [1] => 5d [2] => 1mo [3] => 3mo [4] => 6mo [5] => 1y [6] => 2y [7] => 5y [8] => 10y [9] => ytd [10] => max ) ) [timestamp] =>
Array ( [0] => 1588599000 [1] => 1588599300 [2] => 1588599600 [3] => 1588599900 [4] => 1588600200 [5] => 1588600500 ) [indicators] =>
Array ( [quote] =>
Array ( [0] =>
Array ( [open] =>
Array ( [0] => 13.3599996567 [1] => 13.8599996567 [2] => 13.720000267 [3] => 13.8800001144 [4] => 14.0349998474 [5] => 14.051199913 ) [close] =>
Array ( [0] => 13.9499998093 [1] => 13.7299995422 [2] => 13.8400001526 [3] => 14.0450000763 [4] => 14.0600004196 [5] => 14.1899995804 ) [high] =>
Array ( [0] => 14 [1] => 13.8599996567 [2] => 13.9399995804 [3] => 14.0900001526 [4] => 14.1000003815 [5] => 14.2600002289 ) [low] =>
Array ( [0] => 13.1099996567 [1] => 13.5900001526 [2] => 13.720000267 [3] => 13.8699998856 [4] => 13.8509998322 [5] => 14 ) [volume] =>
Array ( [0] => 124733 [1] => 49489 [2] => 51657 [3] => 48362 [4] => 34055 [5] => 36566 ) ) ) ) ) ) [error] => ) );
You need:
<?php
$data = json_decode(file_get_contents($req_url),true);
$close = $data['chart']['result'][0]['meta']['currentTradingPeriod']['pre']['regular']['post']['tradingPeriods'][0][0]['validRanges']['timestamp']['indicators']['quote'][0]['open']['close'];
echo $close;
?>
UPDATE: Your comment shows different array. You need:
<?php
$req_url = 'https://query1.finance.yahoo.com/v7/finance/chart/SEAS?&interval=5m';
$data = json_decode(file_get_contents($req_url), true);
$close = $data['chart']['result'][0]['indicators']['quote'][0]['close'];
print_r($close);
?>
I am attempting to convert an associative array to a 2D array to allow me to export it to Google Sheets. I've figured out a simplistic solution that works as follows:
$headers = $data["resultSets"][0]["headers"];
$rowSet0 = $data["resultSets"][0]["rowSet"][0];
$rowSet1 = $data["resultSets"][0]["rowSet"][1];
$hackresults = array_map(null, $headers, $rowSet0, $rowSet1);
This produces the following:
(
[0] => Array
(
[0] => SEASON_ID
[1] => 22017
[2] => 22017
)
[1] => Array
(
[0] => Player_ID
[1] => 203954
[2] => 203954
)
[2] => Array
(
[0] => Game_ID
[1] => 0021701118
[2] => 0021701105
)
[3] => Array
(
[0] => GAME_DATE
[1] => MAR 28, 2018
[2] => MAR 26, 2018
)
[4] => Array
(
[0] => MATCHUP
[1] => PHI vs. NYK
[2] => PHI vs. DEN
)
[5] => Array
(
[0] => WL
[1] => W
[2] => W
)
[6] => Array
(
[0] => MIN
[1] => 9
[2] => 27
)
[7] => Array
(
[0] => FGM
[1] => 2
[2] => 6
)
[8] => Array
(
[0] => FGA
[1] => 6
[2] => 12
)
[9] => Array
(
[0] => FG_PCT
[1] => 0.333
[2] => 0.5
)
[10] => Array
(
[0] => FG3M
[1] => 0
[2] => 0
)
[11] => Array
(
[0] => FG3A
[1] => 1
[2] => 1
)
[12] => Array
(
[0] => FG3_PCT
[1] => 0
[2] => 0
)
[13] => Array
(
[0] => FTM
[1] => 1
[2] => 8
)
[14] => Array
(
[0] => FTA
[1] => 2
[2] => 10
)
[15] => Array
(
[0] => FT_PCT
[1] => 0.5
[2] => 0.8
)
[16] => Array
(
[0] => OREB
[1] => 2
[2] => 1
)
[17] => Array
(
[0] => DREB
[1] => 1
[2] => 12
)
[18] => Array
(
[0] => REB
[1] => 3
[2] => 13
)
[19] => Array
(
[0] => AST
[1] => 0
[2] => 2
)
[20] => Array
(
[0] => STL
[1] => 0
[2] => 1
)
[21] => Array
(
[0] => BLK
[1] => 0
[2] => 2
)
[22] => Array
(
[0] => TOV
[1] => 1
[2] => 4
)
[23] => Array
(
[0] => PF
[1] => 1
[2] => 5
)
[24] => Array
(
[0] => PTS
[1] => 5
[2] => 20
)
[25] => Array
(
[0] => PLUS_MINUS
[1] => 7
[2] => 20
)
[26] => Array
(
[0] => VIDEO_AVAILABLE
[1] => 1
[2] => 1
)
)
This is the output I'm looking for, but there are 27 "rowSet"s, and it seems there must be a recursive way of performing this task.
I've looked at a number of custom array_map_recursive style functions but haven't had any success. Apologies and thanks in advance, I am a terrible novice coder!
You can use argument unpacking.
With the ... operator, you can use all the elements under $data["resultSets"][0]["rowSet"] as additional arguments to array_map.
$headers = $data["resultSets"][0]["headers"];
$rowSets = $data["resultSets"][0]["rowSet"];
$results = array_map(null, $headers, ...$rowSets);
(This isn't recursion, but I think it does what you're trying to do.)
I've a multidimensional array looks like below-
Array
(
[0] => Array
(
[0] => Account Number
[1] => Account Title
[2] => Account Type
[3] => Currency
[4] => Available Balance
[5] => Ledger Balance
)
[1] => Array
(
[0] => xxxxxxxx YYYYYYY
)
[2] => Array
(
[0] =>
)
[3] => Array
(
[0] => Date
[1] => Description
[2] => Withdrawal
[3] => Deposit
[4] => Balance
)
[4] => Array
(
[0] =>
)
[5] => Array
(
[0] => `30/08/2018
[1] => EXIM 5287609
[2] => -
[3] => 25000.00
[4] => 62672.880
)
[6] => Array
(
[0] => `03/09/2018
[1] => PRIME 9373059
[2] => -
[3] => 191920.00
[4] => 254592.880
)
[7] => Array
(
[0] => `04/09/2018
[1] => RV CLEARING FEE-CHQ 9373059
[2] => 8.70
[3] => -
[4] => 254584.180
)
[8] => Array
(
[0] => `04/09/2018
[1] => VAT AT SOURCE
[2] => 1.30
[3] => -
[4] => 254582.880
)
[9] => Array
(
[0] => `04/09/2018
[1] => ATM WDR AT 4503 13:55:02
[2] => 20000.00
[3] => -
[4] => 234582.880
)
[10] => Array
(
[0] => `08/09/2018
[1] => ATM WDR AT 4504 11:58:19
[2] => 10000.00
[3] => -
[4] => 224582.880
)
[11] => Array
(
[0] => `09/09/2018
[1] => ATM WDR AT 4500 20:05:19
[2] => 40000.00
[3] => -
[4] => 184582.880
)
[12] => Array
(
[0] => `09/09/2018
[1] => ATM WDR AT 4500 20:05:59
[2] => 40000.00
[3] => -
[4] => 144582.880
)
[13] => Array
(
[0] => `09/09/2018
[1] => ATM WDR AT 4500 20:06:37
[2] => 20000.00
[3] => -
[4] => 124582.880
)
[14] => Array
(
[0] => `12/09/2018
[1] => B ASIA 5904486
[2] => -
[3] => 490000.00
[4] => 614582.880
)
[15] => Array
(
[0] => `12/09/2018
[1] => B ASIA 5904486 RETURN
[2] => 490000.00
[3] => -
[4] => 124582.880
)
[16] => Array
(
[0] => `12/09/2018
[1] => RV CLEARING FEE-CHQ 5904486
[2] => 8.70
[3] => -
[4] => 124574.180
)
[17] => Array
(
[0] => `12/09/2018
[1] => VAT AT SOURCE
[2] => 1.30
[3] => -
[4] => 124572.880
)
[18] => Array
(
[0] => `12/09/2018
[1] => ATM WDR AT 4500 12:31:55
[2] => 20000.00
[3] => -
[4] => 104572.880
)
[19] => Array
(
[0] => `13/09/2018
[1] => ATM WDR AT 4503 14:59:28
[2] => 20000.00
[3] => -
[4] => 84572.880
)
[20] => Array
(
[0] => `16/09/2018
[1] => ATM WDR AT 4500 17:10:04
[2] => 10000.00
[3] => -
[4] => 74572.880
)
[21] => Array
(
[0] => `19/09/2018
[1] => B ASIA 5904486
[2] => -
[3] => 490000.00
[4] => 564572.880
)
[22] => Array
(
[0] => `19/09/2018
[1] => ATM WDR AT 4502 16:24:29
[2] => 40000.00
[3] => -
[4] => 524572.880
)
[23] => Array
(
[0] => `19/09/2018
[1] => ATM WDR AT 4502 16:25:12
[2] => 10000.00
[3] => -
[4] => 514572.880
)
[24] => Array
(
[0] => `20/09/2018
[1] => B ASIA 5904486 RETURN
[2] => 490000.00
[3] => -
[4] => 24572.880
)
[25] => Array
(
[0] => `20/09/2018
[1] => RV CLEARING FEE-CHQ 5904486
[2] => 8.70
[3] => -
[4] => 24564.180
)
[26] => Array
(
[0] => `20/09/2018
[1] => VAT AT SOURCE
[2] => 1.30
[3] => -
[4] => 24562.880
)
[27] => Array
(
[0] => `22/09/2018
[1] => ATM WDR AT 4500 14:09:11
[2] => 15000.00
[3] => -
[4] => 9562.880
)
[28] => Array
(
[0] => `24/09/2018
[1] => CASH DEPOSIT
[2] => -
[3] => 100000.00
[4] => 109562.880
)
[29] => Array
(
[0] => `25/09/2018
[1] => EFT TO PRIME BANK LT
[2] => 45000.00
[3] => -
[4] => 64562.880
)
[30] => Array
(
[0] => `26/09/2018
[1] => ATM WDR AT 4503 11:06:25
[2] => 5000.00
[3] => -
[4] => 59562.880
)
)
Now I need a new array looks like below-
array(
[1] => Array
(
[0] => Date
[1] => Description
[2] => Withdrawal
[3] => Deposit
[4] => Balance
)
[2] => Array
(
[0] => `30/08/2018
[1] => EXIM 5287609
[2] => -
[3] => 25000.00
[4] => 62672.880
)
[3] => Array
(
[0] => `03/09/2018
[1] => PRIME 9373059
[2] => -
[3] => 191920.00
[4] => 254592.880
)
[4] => Array
(
[0] => `04/09/2018
[1] => RV CLEARING FEE-CHQ 9373059
[2] => 8.70
[3] => -
[4] => 254584.180
)
[5] => Array
(
[0] => `04/09/2018
[1] => VAT AT SOURCE
[2] => 1.30
[3] => -
[4] => 254582.880
)
[6] => Array
(
[0] => `04/09/2018
[1] => ATM WDR AT 4503 13:55:02
[2] => 20000.00
[3] => -
[4] => 234582.880
)
[7] => Array
(
[0] => `08/09/2018
[1] => ATM WDR AT 4504 11:58:19
[2] => 10000.00
[3] => -
[4] => 224582.880
)
[8] => Array
(
[0] => `09/09/2018
[1] => ATM WDR AT 4500 20:05:19
[2] => 40000.00
[3] => -
[4] => 184582.880
)
[9] => Array
(
[0] => `09/09/2018
[1] => ATM WDR AT 4500 20:05:59
[2] => 40000.00
[3] => -
[4] => 144582.880
)
[10] => Array
(
[0] => `09/09/2018
[1] => ATM WDR AT 4500 20:06:37
[2] => 20000.00
[3] => -
[4] => 124582.880
)
[11] => Array
(
[0] => `12/09/2018
[1] => B ASIA 5904486
[2] => -
[3] => 490000.00
[4] => 614582.880
)
[12] => Array
(
[0] => `12/09/2018
[1] => B ASIA 5904486 RETURN
[2] => 490000.00
[3] => -
[4] => 124582.880
)
[13] => Array
(
[0] => `12/09/2018
[1] => RV CLEARING FEE-CHQ 5904486
[2] => 8.70
[3] => -
[4] => 124574.180
)
[14] => Array
(
[0] => `12/09/2018
[1] => VAT AT SOURCE
[2] => 1.30
[3] => -
[4] => 124572.880
)
[15] => Array
(
[0] => `12/09/2018
[1] => ATM WDR AT 4500 12:31:55
[2] => 20000.00
[3] => -
[4] => 104572.880
)
[16] => Array
(
[0] => `13/09/2018
[1] => ATM WDR AT 4503 14:59:28
[2] => 20000.00
[3] => -
[4] => 84572.880
)
[17] => Array
(
[0] => `16/09/2018
[1] => ATM WDR AT 4500 17:10:04
[2] => 10000.00
[3] => -
[4] => 74572.880
)
[18] => Array
(
[0] => `19/09/2018
[1] => B ASIA 5904486
[2] => -
[3] => 490000.00
[4] => 564572.880
)
[19] => Array
(
[0] => `19/09/2018
[1] => ATM WDR AT 4502 16:24:29
[2] => 40000.00
[3] => -
[4] => 524572.880
)
[20] => Array
(
[0] => `19/09/2018
[1] => ATM WDR AT 4502 16:25:12
[2] => 10000.00
[3] => -
[4] => 514572.880
)
[21] => Array
(
[0] => `20/09/2018
[1] => B ASIA 5904486 RETURN
[2] => 490000.00
[3] => -
[4] => 24572.880
)
[22] => Array
(
[0] => `20/09/2018
[1] => RV CLEARING FEE-CHQ 5904486
[2] => 8.70
[3] => -
[4] => 24564.180
)
[23] => Array
(
[0] => `20/09/2018
[1] => VAT AT SOURCE
[2] => 1.30
[3] => -
[4] => 24562.880
)
[24] => Array
(
[0] => `22/09/2018
[1] => ATM WDR AT 4500 14:09:11
[2] => 15000.00
[3] => -
[4] => 9562.880
)
[25] => Array
(
[0] => `24/09/2018
[1] => CASH DEPOSIT
[2] => -
[3] => 100000.00
[4] => 109562.880
)
[26] => Array
(
[0] => `25/09/2018
[1] => EFT TO PRIME BANK LT
[2] => 45000.00
[3] => -
[4] => 64562.880
)
[27] => Array
(
[0] => `26/09/2018
[1] => ATM WDR AT 4503 11:06:25
[2] => 5000.00
[3] => -
[4] => 59562.880
)
)
I know by using a loop I can separate my desired arrays and can crate a new array. But without any loop, is it possible to create a new array by PHP built in method?
Advance thanks for all of you who will give me a nice solution.
Note:- array will be too long. It's a bank transaction array so need a fast method which will give output within the shortest time.
You can filter arrays based on it length using array_filter()
$newArr = array_filter($arr, function($item){
return sizeof($item) == 5;
});
If your array is large and you need a fast method, use foreach instead
foreach ($arr as $key=>$item)
sizeof($item) != 5 ? unset($arr[$key]) : "";
All activities on one go...
$length=count($arr);
for($i=0;$i<$length;$i++){
if(count($arr[$i])==4){
// execute desired process
}
}
I am using MultipleIterator() to iterate through two different arrays and get each element.
My code
$d = new MultipleIterator ();
$d->attachIterator ( new ArrayIterator ( $tbl_one_data ) );
$d->attachIterator ( new ArrayIterator ( $tbl_two_data ) );
foreach ( $d as $data ) {
print_r($data);
}
Which generates the following :
My question is how do I loop through the array and return each element? For example I would like to return 2014-11-06 11:31:58.781018. Tried using $data[0][0] but this returns all elements in the first index but I only want one element.
EDIT
print_r($d);
MultipleIterator Object ( [storage:SplObjectStorage:private] => Array ( [00000000583bd67b000000000ac6c449] => Array ( [obj] => ArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [0] => Array ( [0] => 1 [1] => 2014-11-06 11:31:58.781018 [2] => NONE [3] => NONE ) [1] => Array ( [0] => 2 [1] => 2014-11-06 11:31:58.799436 [2] => MANAGER [3] => 500 ) [2] => Array ( [0] => 3 [1] => 2014-11-06 11:31:58.841035 [2] => MANAGER [3] => 501 ) [3] => Array ( [0] => 4 [1] => 2014-11-06 11:33:00.741873 [2] => MANAGER [3] => 500 ) [4] => Array ( [0] => 5 [1] => 2014-11-06 11:33:00.802389 [2] => MANAGER [3] => 501 ) [5] => Array ( [0] => 6 [1] => 2014-11-06 13:15:49.457646 [2] => MANAGER [3] => 500 ) [6] => Array ( [0] => 7 [1] => 2014-11-06 13:37:16.259128 [2] => NONE [3] => NONE ) [7] => Array ( [0] => 8 [1] => 2014-11-06 13:37:16.275201 [2] => NONE [3] => 500 ) [8] => Array ( [0] => 9 [1] => 2014-11-06 13:37:27.682873 [2] => NONE [3] => NONE ) [9] => Array ( [0] => 10 [1] => 2014-11-06 13:37:27.690863 [2] => NONE [3] => 500 ) [10] => Array ( [0] => 11 [1] => 2014-11-06 13:52:21.108003 [2] => MANAGER [3] => 500 ) [11] => Array ( [0] => 12 [1] => 2014-11-06 14:17:01.266769 [2] => NONE [3] => NONE ) [12] => Array ( [0] => 13 [1] => 2014-11-06 14:17:01.279507 [2] => node1-1415283420.0 [3] => 500 ) [13] => Array ( [0] => 14 [1] => 2014-11-06 14:17:02.527183 [2] => node1-1415283420.0 [3] => 500 ) [14] => Array ( [0] => 15 [1] => 2014-11-06 14:17:23.775279 [2] => node1-1415283442.1 [3] => 500 ) ) ) [inf] => ) [00000000583bd67a000000000ac6c449] => Array ( [obj] => ArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [0] => Array ( [0] => NONE [1] => QUEUESTART [2] => [3] => [4] => [5] => [6] => ) [1] => Array ( [0] => Local/120#disc-agents/n [1] => ADDMEMBER [2] => [3] => [4] => [5] => [6] => ) [2] => Array ( [0] => Local/120#disc-agents/n [1] => ADDMEMBER [2] => [3] => [4] => [5] => [6] => ) [3] => Array ( [0] => Local/120#disc-agents/n [1] => REMOVEMEMBER [2] => [3] => [4] => [5] => [6] => ) [4] => Array ( [0] => Local/120#disc-agents/n [1] => REMOVEMEMBER [2] => [3] => [4] => [5] => [6] => ) [5] => Array ( [0] => Local/120#disc-agents/n [1] => ADDMEMBER [2] => [3] => [4] => [5] => [6] => ) [6] => Array ( [0] => Local/120#disc-agents/n [1] => PAUSEALL [2] => [3] => [4] => [5] => [6] => ) [7] => Array ( [0] => Dunc Test [1] => PAUSE [2] => [3] => [4] => [5] => [6] => ) [8] => Array ( [0] => Local/120#disc-agents/n [1] => UNPAUSEALL [2] => [3] => [4] => [5] => [6] => ) [9] => Array ( [0] => Dunc Test [1] => UNPAUSE [2] => [3] => [4] => [5] => [6] => ) [10] => Array ( [0] => Local/120#disc-agents/n [1] => REMOVEMEMBER [2] => [3] => [4] => [5] => [6] => ) [11] => Array ( [0] => NONE [1] => QUEUESTART [2] => [3] => [4] => [5] => [6] => ) [12] => Array ( [0] => NONE [1] => ENTERQUEUE [2] => [3] => 363 [4] => 1 [5] => [6] => ) [13] => Array ( [0] => NONE [1] => ABANDON [2] => 1 [3] => 1 [4] => 1 [5] => [6] => ) [14] => Array ( [0] => NONE [1] => ENTERQUEUE [2] => [3] => 363 [4] => 1 [5] => [6] => ) ) ) [inf] => ) ) )
if this is really output by print_r then $data[0][1] must be '2014-11-06 11:31:58.781018' . I test it by code:
$data = array(array('1','2014-11-06 11:31:58.781018'));
echo '<pre>';
print_r($data); echo '<br>';
echo 'what we want: '.$data[0][1].'<br>';
otput:
Array
(
[0] => Array
(
[0] => 1
[1] => 2014-11-06 11:31:58.781018
)
)
what we want: 2014-11-06 11:31:58.781018
If you have the $data as an array you can access the value: 2014-11-06 11:31:58.781018 by using,
$date = $data[0][1];
I want to get rid of duplicates in my array but I'm still printing duplicates with this:
$getuser = ltrim($top10['url'], " users/" ); //trim url to get user id
$array[$i++] = $getuser;
$dirty = $array;
$clean = array_unique($dirty);
print_r($clean)."<br />";
Input print_r($array)
Array ( [0] => 33 [1] => 3 [2] => 29 [3] => 3104 ) Array ( [0] => 156686 [1] => 5 [2] => 3104 [3] => 1 ) Array ( [0] => 2 [1] => 115023 [2] => 185367 [3] => 180694 ) Array ( [0] => 2 [1] => 5 [2] => 3104 [3] => 139403 ) Array ( [0] => 3110 [1] => 2723 [2] => 8087 [3] => 97410 ) Array ( [0] => 1925 [1] => 60 [2] => 18995 [3] => 2940 ) Array ( [0] => 103205 [1] => 111503 [2] => 2 [3] => 128715 ) Array ( [0] => 3 [1] => 119266 [2] => 4 [3] => 3104 ) Array ( [0] => 32565 [1] => 2743 [2] => 148584 [3] => 3505 ) Array ( [0] => 35282 [1] => 99136 [2] => 54167 [3] => 5326 )
Output print_r($clean);
Array ( [0] => 33 [1] => 3 [2] => 29 [3] => 3104 ) Array ( [0] => 156686 [1] => 5 [2] => 3104 [3] => 1 ) Array ( [0] => 2 [1] => 115023 [2] => 185367 [3] => 180694 ) Array ( [0] => 2 [1] => 5 [2] => 3104 [3] => 139403 ) Array ( [0] => 3110 [1] => 2723 [2] => 8087 [3] => 97410 ) Array ( [0] => 1925 [1] => 60 [2] => 18995 [3] => 2940 ) Array ( [0] => 103205 [1] => 111503 [2] => 2 [3] => 128715 ) Array ( [0] => 3 [1] => 119266 [2] => 4 [3] => 3104 ) Array ( [0] => 32565 [1] => 2743 [2] => 148584 [3] => 3505 ) Array ( [0] => 35282 [1] => 99136 [2] => 54167 [3] => 5326 )
Yes, it seems to be correct. Basically you specify an array to array_unique and it gives you unique items out of the array.
$unique_array = array_unique($your_array);