PHP - Count number of values in a specific index of multidimensional array - php

I have a multidimensional array where I need to get the count of similar values in a specific index and create a new array with the results. I am using PHP 7.3.
For example, I need to count the number of similar values in index [3] .
Desired results MUFA-D = 2, BRD-IS = 3, JBC-BAK-B = 1.
[0] => Array
(
[0] => CHICAGO
[1] => 14
[2] => MUFFIN A LINE
[3] => MUFA-D
[4] => Arm Bearings - Check for play, lubricate if needed.
)
[1] => Array
(
[0] => CHICAGO
[1] => 14
[2] => MUFFIN A LINE
[3] => MUFA-D
[4] => Linkage - Check for wear and broken links.
)
[2] => Array
(
[0] => MEMPHIS
[1] => 05
[2] => BREADING LINE 1
[3] => BRD1-IS
[4] => Gear Box oil level
)
[3] => Array
(
[0] => MEMPHIS
[1] => 05
[2] => BREADING LINE 1
[3] => BRD1-IS
[4] => Bearings visual inspection
)
[4] => Array
(
[0] => MEMPHIS
[1] => 05
[2] => BREADING LINE 1
[3] => BRD1-IS
[4] => Electrical Plug condition
)
[5] => Array
(
[0] => CHICAGO
[1] => 02
[2] => JBC LINE 2
[3] => JBC-BAK-B
[4] => Plate separator shaft
)
)

Using a couple of useful builtin functions you can do
$in = [
['CHICAGO', '14', 'MUFFIN A LINE', 'MUFA-D', 'Arm Bearings - Check for play, lubricate if needed.'],
['CHICAGO', '14', 'MUFFIN A LINE', 'MUFA-D', 'Linkage - Check for wear and broken links.'],
['MEMPHIS', '05', 'BREADING LINE 1', 'BRD1-IS', 'Gear Box oil level'],
['MEMPHIS', '05', 'BREADING LINE 1', 'BRD1-IS', 'Bearings visual inspection'],
['MEMPHIS', '05', 'BREADING LINE 1', 'BRD1-IS', 'Electrical Plug condition'],
['CHICAGO', '02', 'JBC LINE 2', 'JBC-BAK-B', 'Plate separator shaft']
];
function grab3($occ)
{
return $occ[3];
}
print_r(array_count_values(array_map('grab3', $in)));
And the result is an array where the values are now the key of an array and the value is the count
Array
(
[MUFA-D] => 2
[BRD1-IS] => 3
[JBC-BAK-B] => 1
)

You can just loop over the array and use the indexes value as a key in an associative array to count. Then $result will contain your desired results.
$data = [
['CHICAGO', '14', 'MUFFIN A LINE', 'MUFA-D', 'Arm Bearings - Check for play, lubricate if needed.',],
['CHICAGO', '14', 'MUFFIN A LINE', 'MUFA-D', 'Linkage - Check for wear and broken links.',],
['MEMPHIS', '05', 'BREADING LINE 1', 'BRD1 - IS', 'Gear Box oil level',],
['MEMPHIS', '05', 'BREADING LINE 1', 'BRD1 - IS', 'Bearings visual inspection',],
['MEMPHIS', '05', 'BREADING LINE 1', 'BRD1 - IS', 'Electrical Plug condition',],
['CHICAGO', '02', 'JBC LINE 2', 'JBC - BAK - B', 'Plate separator shaft',],
];
$result = [];
foreach ($data as $item) {
$index = $item[3];
$result[$index] = isset($result[$index]) ? $result[$index] + 1 : 1;
}
print_r($result);
Will print
Array
(
[MUFA-D] => 3
[BRD1 - IS] => 4
[JBC - BAK - B] => 2
)

You could use this function on your condition.
function countSimilarValuesByIndex(array $MyArray,int $Index){
$SimilarValues = [];
foreach($MyArray as $Object){
$SimilarValues[$Object[$Index]] = (isset($SimilarValues[$Object[$Index]]))? ++$SimilarValues[$Object[$Index]]:1;
}
return $SimilarValues;
}
$MyArray = [
['CHICAGO', 14, 'MUFFIN A LINE', 'MUFA-D', 'Arm Bearings - Check for play, lubricate if needed.'],
['CHICAGO', 14, 'MUFFIN A LINE', 'MUFA-D', 'Linkage - Check for wear and broken links.'],
['MEMPHIS', 05, 'BREADING LINE 1', 'BRD1-IS', 'Gear Box oil level'],
['MEMPHIS', 05, 'BREADING LINE 1', 'BRD1-IS', 'Bearings visual inspection'],
['MEMPHIS', 05, 'BREADING LINE 1', 'BRD1-IS', 'Electrical Plug condition'],
['CHICAGO', 02, 'JBC LINE 2', 'JBC-BAK-B', 'Plate separator shaft']
];
$Index = 1;
$YourResult = countSimilarValuesByIndex($MyArray,$Index);
Result:
[
[14] => 2,
[5] => 3,
[2] => 1
]

Related

How to add sum values of array according to keys in php

I have an array of php like this
Array
(
[0] => Array
(
[Sr_No] => 1
[Asan_Category] => Warm-Up
[Asan_Cat_Val] => 8
[Asan_Sub_Category] => Ankle
[Asan_Sub_Cat_Val] => 35
[Asan_Name] => General Ankle Warm up
[Asan_Name_Val] => 447
[Prescribed_Steps] => 40
[Prescribed_Ratio] => 00
[Actual_Steps] => 12
[Actual_Ratio] => 0
)
[1] => Array
(
[Sr_No] => 2
[Asan_Category] => Warm-Up
[Asan_Cat_Val] => 8
[Asan_Sub_Category] => Knee
[Asan_Sub_Cat_Val] => 111
[Asan_Name] => General knee warm up
[Asan_Name_Val] => 464
[Prescribed_Steps] => 20
[Prescribed_Ratio] => 00
[Actual_Steps] => 14
[Actual_Ratio] => 0
)
[2] => Array
(
[Sr_No] => 1
[Asan_Category] => Warm-Up
[Asan_Cat_Val] => 8
[Asan_Sub_Category] => Ankle
[Asan_Sub_Cat_Val] => 35
[Asan_Name] => General Ankle Warm up
[Asan_Name_Val] => 447
[Prescribed_Steps] => 40
[Prescribed_Ratio] => 00
[Actual_Steps] => 10
[Actual_Ratio] => 0
)
[3] => Array
(
[Sr_No] => 2
[Asan_Category] => Warm-Up
[Asan_Cat_Val] => 8
[Asan_Sub_Category] => Knee
[Asan_Sub_Cat_Val] => 111
[Asan_Name] => General knee warm up
[Asan_Name_Val] => 464
[Prescribed_Steps] => 20
[Prescribed_Ratio] => 00
[Actual_Steps] => 9
[Actual_Ratio] => 0
)
)
The desired output I want
Array
(
[0] => Array
(
[Asan_Id] => 447
[Asan_Category] => Warm-Up
[Asan_Sub_Category] => Ankle
[Asan_Name] => General Ankle Warm up
[Prescribed_Steps] => 40
[Prescribed_Ratio] => 00
[Total_Steps] => 22
)
[1] => Array
(
[Asan_Id] => 464
[Asan_Category] => Warm-Up
[Asan_Sub_Category] => Knee
[Asan_Name] => General knee warm up
[Prescribed_Steps] => 20
[Prescribed_Ratio] => 00
[Total_Steps] => 23
)
)
I want those data who are repeating become one but their different actual steps become total steps with their sum.
Please help me because I have tried some code but did not success like this
$asan=[];
$total_steps=0;
foreach ($aasan_details as $key) {
$total_steps += $key['Actual_Steps'];
if(!in_array($key['Asan_Name_Val'],$asan))
{
$asan[] = $key['Asan_Name_Val'];
$lookup[] = array("Asan_Id"=>$key['Asan_Name_Val'],
"Asan_Category"=>$key['Asan_Category'],
"Asan_Sub_Category"=>$key['Asan_Sub_Category'],
"Asan_Name"=>$key['Asan_Name'],
"Prescribed_Steps"=>$key['Prescribed_Steps'],
"Prescribed_Ratio"=>$key['Prescribed_Ratio'],
'Total_Steps'=>$total_steps);
}
}
It is not working , what should I do guys , please help me out
where $aasan_details is the array which I showed above and the in lookup array I am getting uniqe values but not getting their total
The best solution would be to move this into a database and use a query to perform that exact operation for you.
But if you have to do it in code, you could use a keyed array to basically group them up by however many fields need to match for them to be conjoined:
e.g.
foreach ..
$consolidated[$item['Asan_Cat_Val']][$item['Asan_Sub_Cat_Val']][] = $item;
Then make a couple of nested loops to go across this and sum everything up.
There a few useful techniques to explain here...
You can reduce eye-strain in your looped array declarations by establishing a collection of keys that you know you want to retain in (copy to) the output array. This spares you having to type out each $keyName => $row[$keyName], like this (but ultimately make yourself happy).
Declare temporary associative keys (using $id) while building your output array to allow isset() to make super fast checks for a pre-existing group.
If a group is not yet set, then store the data with the new keys along with the data with the original keys. No arithmetic is necessary. The + symbols in my snippet are not "addition operators", they are "array union operators" -- they are merging the three arrays without a function call (otherwise array_merge() would do the same).
When finished iterating the array, you may choose to re-index the result (remove the temporary associative keys) by calling array_values(). If you are not bothered by the existence of these temporary keys, you can omit the function call.
If a group has been encountered before, you only need to modify the Total_steps. Use an addition-assignment operator (+=) for the briefest syntax.
Code: (Demo)
$keysToKeep = array_flip(['Asan_Category', 'Asan_Sub_Category', 'Asan_Name', 'Prescribed_Steps', 'Prescribed_Ratio']);
foreach ($array as $row) {
$id = $row['Asan_Name_Val'];
if (!isset($result[$id])) {
$result[$id] = ['Asan_Id' => $id] + array_intersect_key($row, $keysToKeep) + ['Total_Steps' => $row['Actual_Steps']];
} else {
$result[$id]['Total_Steps'] += $row['Actual_Steps'];
}
}
var_export(array_values($result));
Output:
array (
0 =>
array (
'Asan_Id' => '447',
'Asan_Category' => 'Warm-Up',
'Asan_Sub_Category' => 'Ankle',
'Asan_Name' => 'General Ankle Warm up',
'Prescribed_Steps' => '40',
'Prescribed_Ratio' => '00',
'Total_Steps' => 22,
),
1 =>
array (
'Asan_Id' => '464',
'Asan_Category' => 'Warm-Up',
'Asan_Sub_Category' => 'Knee',
'Asan_Name' => 'General knee warm up',
'Prescribed_Steps' => '20',
'Prescribed_Ratio' => '00',
'Total_Steps' => 23,
),
)

PHP convert formatted string (title + values) to multidimensional array

I would like to convert this formatted string to multidimensional array but I can't manage to do it.
The goal is to extract titles header (Dreg Time, FN, SS_ID, MAC, Sector ID, Type, Reason, CMPNT, Basic, Cid) and associating the corresponding values.
Because in the finality I would need to process the data in the "Reason" column.
String:
$log = ": mss get dereg_log 2 500
---------- MODEM 2 MAC ---------
Dreg Time FN SS_ID MAC Sector ID Type Reason CMPNT Basic Cid
2017/08/29 08:20:39:627 0x4da9f0 8277 00:24:a0:xx:xx:xx 1 2 25 0 86
2017/08/29 07:17:33:478 0x421c02 8238 00:23:a2:xx:xx:xx 1 3 59 0 47
2017/08/29 06:00:43:232 0x340a41 8508 00:23:a2:xx:xx:xx 1 1 6 13 317
Total Deregistrations since sector active in sector 1: 9576
Derigistrations since dreg log last reset in sector 1: 9576
Deregistration Types:
DEREG_MSS_IMMEDIATE = 0
DEREG_MSS_DREG_REQ_FROM_AP = 1
DEREG_MSS_DREG_REQ_FROM_MS = 2
DEREG_MSS_RNG_RSP_ABORT_FROM_AP = 3
DEREG_MSS_CONTACT_LOST = 4
---------------------------------
2017-Aug-29 08:31:53.860";
Desired Array:
Array
(
[0] => Array
(
[Dreg Time] => '2017/08/29 08:20:39:627'
[FN] => '0x4da9f0'
[SS_ID] => '8277'
[MAC] => '00:24:a0:xx:xx:xx'
[Sector ID] => '1'
[Type] => '2'
[Reason] => '25'
[CMPNT] => '0'
[Basic Cid] => '86'
)
[1] => Array
(
[Dreg Time] => '2017/08/29 07:17:33:478'
[FN] => '0x421c02'
[SS_ID] => '8238'
[MAC] => '00:23:a2:xx:xx:xx'
[Sector ID] => '1'
[Type] => '3'
[Reason] => '59'
[CMPNT] => '0'
[Basic Cid] => '47'
)
[2] => Array
(
[Dreg Time] => '2017/08/29 06:00:43:232'
[FN] => '0x340a41'
[SS_ID] => '8508'
[MAC] => '00:23:a2:xx:xx:xx'
[Sector ID] => '1'
[Type] => '1'
[Reason] => '6'
[CMPNT] => '13'
[Basic Cid] => '317'
)
)
Code tried:
echo '<pre>';
// remove blank lines
$log = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $log);
// remove new lines
$log = preg_replace('/^.+\n.+\n/', '', $log);
$lines = explode( "\n\n", $log );
$return = array();
foreach ($lines as $line) {
$items = explode("\n", $line);
$return[array_shift($items)] = $items;
}
print_r($return);
Result:
Array
(
[Dreg Time FN SS_ID MAC Sector ID Type Reason CMPNT Basic Cid] => Array
(
[0] => 2017/08/29 08:20:39:627 0x4da9f0 8277 00:24:a0:xx:xx:xx 1 2 25 0 86
[1] => 2017/08/29 07:17:33:478 0x421c02 8238 00:23:a2:xx:xx:xx 1 3 59 0 47
[2] => 2017/08/29 06:00:43:232 0x340a41 8508 00:23:a2:xx:xx:xx 1 1 6 13 317
[3] => Total Deregistrations since sector active in sector 1: 9576
[4] => Derigistrations since dreg log last reset in sector 1: 9576
[5] => Deregistration Types:
[6] => DEREG_MSS_IMMEDIATE = 0
[7] => DEREG_MSS_DREG_REQ_FROM_AP = 1
[8] => DEREG_MSS_DREG_REQ_FROM_MS = 2
[9] => DEREG_MSS_RNG_RSP_ABORT_FROM_AP = 3
[10] => DEREG_MSS_CONTACT_LOST = 4
[11] => ---------------------------------
[12] => 2017-Aug-29 08:31:53.860
)
)
Your code was an incomplete attempt, and contained a few errors - e.g. you removed newlines from the log, and then tried split the string based on newlines! Then you tried to split a single line by newline, when clearly a single line cannot, by implication, contain a newline. Also the code just naively ran through each line and added it directly to the array rather than creating an associative array within each index, as shown in the desired output. And lastly it did nothing to try and identify which lines actually contained the desired output.
This will do it:
$log = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $log);
$lines = explode( "\n", $log );
$return = array();
foreach ($lines as $line) {
$line = preg_replace("/\s+/", " ", $line); //condense and standardise the whitespace between each item, so that explode can work.
$items = explode(" ", $line);
if (count($items) == 10 && preg_match("/^[0-9]{4}/", $items[0])) //restrict to lines starting with the year, and with the correct number of columns
$return[] = array(
"Dreg Time" => $items[0]." ".$items[1],
"FN" => $items[2],
"SS_ID" => $items[3],
"MAC" => $items[4],
"Sector_ID" => $items[5],
"Type" => $items[6],
"Reason" => $items[7],
"CMPNT" => $items[8],
"Basic_Cid" => $items[9]
);
}
echo "<pre>".var_export($return, true)."</pre>";

How to find repeated array value when the key is always unique?

Array
(
[02-i-said-i-m-naruto.mp3] => 99
[018 APNE - TERE SANG.mp3] => 110
[04-sapana.mp3] => 133
[04 Kurnu Kuraunu.MP3] => 220
[005LAD~1.MP3] => 221
[04-akon-troublemaker_ft._sweet_rush - Copy.mp3] => 237
[04--somebodys_me.mp3] => 240
[01-school_of_rock_-_school_of_rock-xxl.mp3] => 253
[007. The Black Eyed Peas - Imma Be.mp3] => 257
[04 Timi Hau.mp3] => 266
[04-jennifer_lopez-(what_is)_love_(produced_by_dmile).mp3] => 267
[04-LIL~1.mp3] => 275
[034.Simple Plan - Perfect.mp3] => 278
[04 THE REAL SLIM SHADY.MP3] => 287
[007 thoda sa pyar hua hai(01).mp3] => 293
[02-pearl_jam-even_flow.mp3] => 294
[04-TUM~yuvraj.mp3] => 337
[01 - MTV Unplugged - Arjit Singh - Dua [DJMaza].mp3] => 339
[015 METRO - Alvida.mp3] => 341
[03 - Sabbra Cadabra.mp3] => 380
[04 - Sabbra Cadabra.mp3] => 380
[03 - The Unforgiven II.mp3] => 396
[04 - The Unforgiven II.mp3] => 396
)
This is the array that my current php processor generate (that generates the value in ascending order using asort()). Now I need to find the duplicate songs by song duration. Forexample, 03 - Sabbra Cadabra.mp3 is duplicate there. duplicate's duration is 380 seconds. I want something that would count number of 380 in the array values or bold the repeated key in regard of values. I tried to use array_count_values($arr) but that didnt help.
Warning: array_count_values() [function.array-count-values]: Can only count STRING and INTEGER values! in index.php on line 23
Try parsing the array values in a foreach loop.
$last= '';
$match_array = array();
foreach ( $array_name as $key => $value )
{
if($value == $last) {
$match_array[] = $value;
}
$last= $value;
{
$match_array should give you the duplicate entries.
I think array_unique and array_diff_assoc are much better options.
Following code will give you those array which are having duplicate time values:
$array = array
(
'02-i-said-i-m-naruto.mp3' => 99,
'018 APNE - TERE SANG.mp3' => 110,
'04-sapana.mp3' => 133,
'04 Kurnu Kuraunu.MP3' => 220,
'005LAD~1.MP3' => 221,
'04-akon-troublemaker_ft._sweet_rush - Copy.mp3' => 237,
'04--somebodys_me.mp3' => 240,
'01-school_of_rock_-_school_of_rock-xxl.mp3' => 253,
'007. The Black Eyed Peas - Imma Be.mp3' => 257,
'04 Timi Hau.mp3' => 266,
'04-jennifer_lopez-(what_is)_love_(produced_by_dmile).mp3' => 267,
'04-LIL~1.mp3' => 275,
'034.Simple Plan - Perfect.mp3' => 278,
'04 THE REAL SLIM SHADY.MP3' => 287,
'007 thoda sa pyar hua hai(01).mp3' => 293,
'02-pearl_jam-even_flow.mp3' => 294,
'04-TUM~yuvraj.mp3' => 337,
'01 - MTV Unplugged - Arjit Singh - Dua [DJMaza].mp3' => 339,
'015 METRO - Alvida.mp3' => 341,
'03 - Sabbra Cadabra.mp3' => 380,
'04 - Sabbra Cadabra.mp3' => 380,
'03 - The Unforgiven II.mp3' => 396,
'04 - The Unforgiven II.mp3' => 396,
);
$arrayUnique = array_unique($array);
print_r(array_diff_assoc($array, $arrayUnique));
Will give:
Array
(
[04 - Sabbra Cadabra.mp3] => 380
[04 - The Unforgiven II.mp3] => 396
)
Eliminate the two first lines and add your array var as $array if you want.
$dump = "array ( '02-i-said-i-m-naruto.mp3' => '99', '018 APNE - TERE SANG.mp3' => '110', '04-sapana.mp3' => '133', '04 Kurnu Kuraunu.MP3' => '220', '005LAD~1.MP3' => '221', '04-akon-troublemaker_ft._sweet_rush - Copy.mp3' => '237', '04--somebodys_me.mp3' => '240', '01-school_of_rock_-_school_of_rock-xxl.mp3' => '253', '007. The Black Eyed Peas - Imma Be.mp3' => '257', '04 Timi Hau.mp3' => '266', '04-jennifer_lopez-(what_is)_love_(produced_by_dmile).mp3' => '267', '04-LIL~1.mp3' => '275', '034.Simple Plan - Perfect.mp3' => '278', '04 THE REAL SLIM SHADY.MP3' => '287', '007 thoda sa pyar hua hai(01).mp3' => '293', '02-pearl_jam-even_flow.mp3' => '294', '04-TUM~yuvraj.mp3' => '337', '01 - MTV Unplugged - Arjit Singh - Dua [DJMaza].mp3' => '339', '015 METRO - Alvida.mp3' => '341', '03 - Sabbra Cadabra.mp3' => '380', '04 - Sabbra Cadabra.mp3' => '380', '03 - The Unforgiven II.mp3' => '396', '04 - The Unforgiven II.mp3' => '396', )";
eval("\$array=$dump;");
$array1 = array_count_values($array);
print_r(array_filter($array1, "duplicate"));
function duplicate($var) {
return $var > 1;
}

how to get data on month base from array in php

I have data in the following form
Array
(
[0] => Array
(
[event_id] => 2042632
[event_name] => Georgia Tech Yellow Jackets vs. North Carolina Tar Heels
[event_payment] => 156
[payment_status] => 1
[event_date] => 2014-01-29
)
[1] => Array
(
[event_id] => 2042632
[event_name] => Georgia Tech Yellow Jackets vs. North Carolina Tar Heels
[event_payment] => 89
[payment_status] => 1
[event_date] => 2014-01-29
)
[2] => Array
(
[event_id] => 2042632
[event_name] => Georgia Tech Yellow Jackets vs. North Carolina Tar Heels
[event_payment] => 772
[payment_status] => 1
[event_date] => 2014-01-29
)
[3] => Array
(
[event_id] => 2042633
[event_name] => Georgia Tech Yellow Jackets vs. North Carolina Tar Heels
[event_payment] => 256
[payment_status] => 0
[event_date] => 2013-12-29
)
)
All I want now to show data in the following format after getting from this array:
January
Event-name, payment, status
georgia.. 1234, 0
georgia.. 3456, 1
December
Event-name, payment, status
georgia.. 1234, 0
georgia.. 3456, 1
and so on and so forth.
please guide me how to do that..
Try
$result = array();
foreach($arr as $ar){
$date = DateTime::createFromFormat("Y-m-d", $ar['event_date']);
$month = $date->format('F');
$year = $date->format('Y');
$result[$year][$month][] = $ar;
}
See demo here
$res= array();
foreach($arr as $key => $val) // $arr is your actual array
{
$month = date('F-Y', strtotime($val['event_date']));
$res[$month][] = $val;
}
Now you get will result as
[January-2014] = array(a1,a2...)
[December-2014] = array(a1,a2...)
Here I only suggest how to sort an array by date. I hope you can do the rest of the work yourself.
function cmp($a, $b) {
return (new DateTime($a['event_date']))->getTimestamp() < (new DateTime($b['event_date']))->getTimestamp()? -1 : 1;
}
usort($array, 'cmp');
$curr_month = 0;
foreach ($array as $elem) {
// output elements of array based on month
// ...
}

PHP: Determine number of characters that come before a dash in a string

If I have a bunch of strings like XXX-WYC-5b, where XXX is any value between 1 and 999, how do I determine the length of XXX?
So I might have:
1: 6-WYC-5b
2: 32-WYC-5b
3: 932-W-5b
4: 22-XYQ-5b
5: 914-WYC-5b
And I want it to tell me the length of XXX, so:
1: 1 character
2: 2 characters
3: 3 characters
4: 2 characters
5: 3 characters
I would also like to know the value itself, so:
1: 6
2: 32
3: 932
4: 22
5: 914
I keep thinking there's a way to do this using substr_count() and explode(), but I can't seem to figure it out. Thanks very much for your help.
Use PHP's built-in string position function. Because it starts counting at 0, you don't even have to adjust the output:
$pos = strpos($string, "-");
For the second part, use PHP's substring function:
return substr($string, 0, $pos);
a different approach you may want to try:
<?php
$str[] = '6-WYC-5b';
$str[] = '32-WYC-5b';
$str[] = '932-W-5b';
$str[] = '22-XYQ-5b';
$str[] = '914-WYC-5b';
foreach($str as $v){
$result[] = getval($v);
}
function getval($value){
$seg = explode('-',$value);
return array('int'=>$seg[0],'intlen'=>strlen($seg[0]),'char'=>$seg[1],'charlen'=>strlen($seg[1]),'last'=>$seg[2],'lastlen'=>strlen($seg[2]));
}
print_r($result);
?>
outputs:
Array
(
[0] => Array
(
[int] => 6
[intlen] => 1
[char] => WYC
[charlen] => 3
[last] => 5b
[lastlen] => 2
)
[1] => Array
(
[int] => 32
[intlen] => 2
[char] => WYC
[charlen] => 3
[last] => 5b
[lastlen] => 2
)
[2] => Array
(
[int] => 932
[intlen] => 3
[char] => W
[charlen] => 1
[last] => 5b
[lastlen] => 2
)
[3] => Array
(
[int] => 22
[intlen] => 2
[char] => XYQ
[charlen] => 3
[last] => 5b
[lastlen] => 2
)
[4] => Array
(
[int] => 914
[intlen] => 3
[char] => WYC
[charlen] => 3
[last] => 5b
[lastlen] => 2
)
)

Categories