9 Replies - 1495 Views - Last Post: 18 October 2010 - 09:10 AM Rate Topic: -----

#1 JordanH  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 46
  • Joined: 28-February 09

Search array for values from database

Posted 18 October 2010 - 05:44 AM

I have a database filled with employee ID's and corresponding employee names for each employee ID. Is there a way I can search an array for employee ID's from the database? Google is not helping me, I think because I'm not sure how to word my search.

My idea is to have something like, array_search($empID, $currentArray). And then loop through each employee ID from the database, and compare it the $currentArray? I doubt this is the most efficient way but I am still learning so any help would be appreciated. Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Search array for values from database

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6079
  • View blog
  • Posts: 23,550
  • Joined: 23-August 08

Re: Search array for values from database

Posted 18 October 2010 - 05:55 AM

There are a lot of array functions available to you, but shouldn't you be using SQL for getting the data you want from the DB?
Was This Post Helpful? 1
  • +
  • -

#3 JordanH  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 46
  • Joined: 28-February 09

Re: Search array for values from database

Posted 18 October 2010 - 06:14 AM

View PostJackOfAllTrades, on 18 October 2010 - 04:55 AM, said:

There are a lot of array functions available to you, but shouldn't you be using SQL for getting the data you want from the DB?


Whats really going on here is that I am trying to import paystubs. I do this by converting a PDF file to txt then read the txt file into an array in PHP. I can't just go every 28th line for example and get the employee ID because the ID's are not every 28th index in the array. So I figured the next best way is to search for the ID's. I have a drupal database any every username has an employee ID associated with it. Im looking to search my array that is the paystub for a matching employee ID from my database. If that makes sense


here is my code if it might help:

<?php 

//this variable tells us how many drupal nodes or 'paystub pages' we need to create
$nodeCount = 0;
$i = 0;

//needed for creating a drupal node
//for this code to work this script must be run from the root of the drupal installation
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if ($handle = opendir('/var/www/html/pay.mistequaygroup.com/upload')) 
{

    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) 
    {
       if ($file != "." && $file != "..") 
       {
            $nodeCount++;
            //We convert the pdf documents into text documents and move put them in the converted folder
            $command = "pdftotext /var/www/html/pay.mistequaygroup.com/upload/" . $file . " /var/www/html/pay.mistequaygroup.com/upload/converted/" . $file . ".txt";
            //Execute the command above
            $output = exec($command);
                    
            //mark all the spots that TO THE ORDER OF shows up
            //echo array_search("TO THE ORDER OF", $currentArray);
            
            //echo $userName;
            
            
            //extract the employees name
            
            
            //print_r($currentArray);
            //echo '<pre>';
            //echo array_search("DATE AMOUNT", $currentArray);
            //echo '</pre>';
                        
        }    
    }        
    closedir($handle);        
}

//subtract two because the folders "array" and "converted" are included because PHP does not differentiate
//between folders and files
$nodeCount = $nodeCount - 2; 

echo "<br />";
echo "I counted $nodeCount pdf files";
echo "<br />";

//open the directory
if ($handle2 = opendir('/var/www/html/pay.mistequaygroup.com/upload/converted')) 
{
    //check to see if we have reached the last file of our directory, if not stay in loop
    while (false !== ($currentText = readdir($handle2))) 
    {
        //filter out files named . and ..
       if ($currentText != "." && $currentText != "..") 
       {
               //Create a file for array to be printed to
               $createArray = fopen("/var/www/html/pay.mistequaygroup.com/upload/arrays/" . $currentText . ".txt", "w+") or die ("Cannot find file to create array, ID 2");
               
               
               //read the file we are on from the loop into the array 
               $currentArray = file("/var/www/html/pay.mistequaygroup.com/upload/converted/" . $currentText, FILE_SKIP_EMPTY_LINES) or die ("Cannot find file to create array, ID 1");

               //$countArray = array_search(". . . . . . . . . .", $currentArray);
               
               //echo $countArray;
               
               //print array to .txt file for debugging purposes
               $out = print_r($currentArray, true);
               fwrite($createArray, $out);
               fclose($createArray);
               
               
               //Loop?
               array_search($empID, $currentArray);
            
               //need to loop through the array we are on, looking for numbers that match the employee ID's 
               //OR we might have to search for names within a string of text and then get the corresponding ID for that user from the database? 
               
               //brainstorming 
               $query = SELECT * FROM `profile_values` WHERE `fid` = 2 AND `value` = $employeeID; 
                         
       }
     }

}
            

?>

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6079
  • View blog
  • Posts: 23,550
  • Joined: 23-August 08

Re: Search array for values from database

Posted 18 October 2010 - 06:42 AM

OK, so it's not a SQL thing. What does an element of the array you're searching look like?
Was This Post Helpful? 1
  • +
  • -

#5 JordanH  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 46
  • Joined: 28-February 09

Re: Search array for values from database

Posted 18 October 2010 - 06:53 AM

View PostJackOfAllTrades, on 18 October 2010 - 05:42 AM, said:

OK, so it's not a SQL thing. What does an element of the array you're searching look like?


Here is an example of one array, removed all sensitive info.

Array
(
    [0] => . . . . . . . . . . *********************************

    [1] => DATE AMOUNT

    [2] => 

    [3] => 09/04/2009

    [4] => 

    [5] => $453.20

    [6] => 

    [7] => PAY

    [8] => 

    [9] => FOUR HUNDRED FIFTY THREE DOLLARS and 20 CENTS

    [10] => 

    [11] => TO THE ORDER OF

    [12] => 

    [13] => ********** ****************** ***********

    [14] => 

    [15] => Bank Routing No.

    [16] => 

    [17] => Bank Account Number

    [18] => 

    [19] => Deposit Amount

    [20] => 

    [21] => ******

    [22] => 

    [23] => ******

    [24] => 

    [25] => *****

    [26] => 

    [27] => NON NEGOTIABLE

    [28] => 9871

    [29] => EMPLOYEE NO.

    [30] => 

    [31] => 01

    [32] => SHIFT

    [33] => 

    [34] => MIC

    [35] => LOCATION HRS/UNITS

    [36] => 

    [37] => **************

    [38] => EMPLOYEE NAME CURRENT AMOUNT YEAR TO DATE

    [39] => 

    [40] => 08/30/2009

    [41] => PERIOD END

    [42] => 

    [43] => EARNINGS

    [44] => 

    [45] => DEDUCTIONS

    [46] => 

    [47] => CURRENT AMOUNT

    [48] => 

    [49] => YEAR TO DATE

    [50] => 

    [51] => Regular Pay Overtime Pay Vacation Pay Holiday Pay

    [52] => 

    [53] => 32.000 4.000 8.000 0.000

    [54] => 

    [55] => 416.00 78.00 104.00 0.00

    [56] => 

    [57] => 16892.65 212.55 728.00 520.00

    [58] => 

    [59] => Federal Income Medicare Tax FICA Tax ****** Income ************8 Non Res Hth Ins. Co-Pay Dental Co-Pay

    [60] => 

    [61] => 51.97 8.34 35.67 22.02 4.17 20.63 2.00

    [62] => 

    [63] => 1518.43 255.29 1091.79 657.53 126.91 679.12 65.48

    [64] => 

    [65] => 598.00

    [66] => CURRENT EARNINGS

    [67] => 

    [68] => 144.80

    [69] => CURRENT DEDUCTIONS

    [70] => 

    [71] => 453.20

    [72] => NET PAY

    [73] => 

    [74] => 18353.20

    [75] => Y.T.D. EARNINGS

    [76] => 

    [77] => 4394.55

    [78] => Y.T.D. DEDUCTIONS

    [79] => 

    [80] => 13958.65

    [81] => Y.T.D. NET PAY

    [82] => 

    [83] => . . . . . . . . . . ********************8

    [84] => DATE AMOUNT

    [85] => 

    [86] => 09/04/2009

    [87] => 

    [88] => $568.29

    [89] => 

    [90] => PAY

    [91] => 

    [92] => FIVE HUNDRED SIXTY EIGHT DOLLARS and 29 CENTS

    [93] => 

    [94] => TO THE ORDER OF

    [95] => 

    [96] => D************************** ******

    [97] => 

    [98] => Bank Routing No.

    [99] => 

    [100] => Bank Account Number

    [101] => 

    [102] => Deposit Amount

    [103] => 

    [104] => *********

    [105] => 

    [106] => ********8

    [107] => 

    [108] => 568.29

    [109] => 

    [110] => NON NEGOTIABLE

    [111] => 9850

    [112] => EMPLOYEE NO.

    [113] => 

    [114] => 01

    [115] => SHIFT

    [116] => 

    [117] => MIC

    [118] => LOCATION HRS/UNITS

    [119] => 

    [120] => ************8

    [121] => EMPLOYEE NAME CURRENT AMOUNT YEAR TO DATE

    [122] => 

    [123] => 08/30/2009

    [124] => PERIOD END

    [125] => 

    [126] => EARNINGS

    [127] => 

    [128] => DEDUCTIONS

    [129] => 

    [130] => CURRENT AMOUNT

    [131] => 

    [132] => YEAR TO DATE

    [133] => 

    [134] => Regular Pay Overtime Pay Vacation Pay Holiday Pay

    [135] => 

    [136] => 40.000 5.000 0.000 0.000

    [137] => 

    [138] => 680.00 127.50 0.00 0.00

    [139] => 

    [140] => 22525.29 1197.23 1020.00 680.00

    [141] => 

    [142] => Federal Income Medicare Tax FICA Tax ******8 Income S****** Non Res Hth Ins. Co-Pay Dental Co-Pay

    [143] => 

    [144] => 97.28 11.06 47.30 33.18 5.72 40.67 4.00

    [145] => 

    [146] => 2915.90 346.23 1480.82 1038.98 179.03 1401.68 137.10

    [147] => 

    [148] => 807.50

    [149] => CURRENT EARNINGS

    [150] => 

    [151] => 239.21

    [152] => CURRENT DEDUCTIONS

    [153] => 

    [154] => 568.29

    [155] => NET PAY

    [156] => 

    [157] => 25422.52

    [158] => Y.T.D. EARNINGS

    [159] => 

    [160] => 7499.74

    [161] => Y.T.D. DEDUCTIONS

    [162] => 

    [163] => 17922.78

    [164] => Y.T.D. NET PAY

    [165] => 

    [166] => 
)



The numbers im looking to cut out and associate with an employee are index [28] = 9871 and [111] = 9850. Note there are two paystubs here. This array is one pdf file that was converted to a .txt document then turned into an array. I was thinking, either search for the employeeID's to figure out whos paystub it is or search by the name of the employee. Then somehow select the right amount of data from the array and insert it into a drupal node. The more I think this through the harder it seems though, my lack of planning skills shows.
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6079
  • View blog
  • Posts: 23,550
  • Joined: 23-August 08

Re: Search array for values from database

Posted 18 October 2010 - 07:05 AM

Are these values always at the same index in the array? If so, just pull them out directly. I may be misunderstanding what you need to do.
Was This Post Helpful? 0
  • +
  • -

#7 JordanH  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 46
  • Joined: 28-February 09

Re: Search array for values from database

Posted 18 October 2010 - 07:46 AM

View PostJackOfAllTrades, on 18 October 2010 - 06:05 AM, said:

Are these values always at the same index in the array? If so, just pull them out directly. I may be misunderstanding what you need to do.


I will double check my array's but I do not think they are always at the same index because different people have different deductions so there could be more or less data on each paystub. Initially I thought I would be able to just pull them from certain indexes but it does not appear that way anymore. I will take a close look at it to be sure and post back here in a bit. Thank you for all your help, its nice to have someone else to look at this with!
Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6079
  • View blog
  • Posts: 23,550
  • Joined: 23-August 08

Re: Search array for values from database

Posted 18 October 2010 - 08:17 AM

OK, well if it's not in the same array index each time then of course you are going to have to search for the ID. Not sure there's a more efficient way to do it.
Was This Post Helpful? 0
  • +
  • -

#9 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,598
  • Joined: 08-August 08

Re: Search array for values from database

Posted 18 October 2010 - 08:30 AM

If it's not the same index each time, then you were on the right track with array_search, but you need to search for something that will not change for each file. The ID will change, but hopefully "EMPLOYEE NO." will not.

<?php
$x = Array
(
    0 =>". . . . . . . . . . *********************************", 
    1 =>"DATE AMOUNT", 
    2 =>"", 
    3 =>"09/04/2009", 
    4 =>"", 
    5 =>"$453.20", 
    6 =>"", 
    7 =>"PAY", 
    8 =>"", 
    9 =>"FOUR HUNDRED FIFTY THREE DOLLARS and 20 CENTS", 
    10 =>"", 
    11 =>"TO THE ORDER OF", 
    12 =>"", 
    13 =>"********** ****************** ***********", 
    14 =>"", 
    15 =>"Bank Routing No.", 
    16 =>"", 
    17 =>"Bank Account Number", 
    18 =>"", 
    19 =>"Deposit Amount", 
    20 =>"", 
    21 =>"******", 
    22 =>"", 
    23 =>"******", 
    24 =>"", 
    25 =>"*****", 
    26 =>"", 
    27 =>"NON NEGOTIABLE", 
    28 =>"9871", 
    29 =>"EMPLOYEE NO.", 
    30 =>"", 
    31 =>"01", 
    32 =>"SHIFT", 
    33 =>"", 
    34 =>"MIC", 
    35 =>"LOCATION HRS/UNITS", 
    36 =>"", 
    37 =>"**************", 
    38 =>"EMPLOYEE NAME CURRENT AMOUNT YEAR TO DATE", 
    39 =>"", 
    40 =>"08/30/2009", 
    41 =>"PERIOD END", 
    42 =>"", 
    43 =>"EARNINGS", 
    44 =>"", 
    45 =>"DEDUCTIONS", 
    46 =>"", 
    47 =>"CURRENT AMOUNT", 
    48 =>"", 
    49 =>"YEAR TO DATE", 
    50 =>"", 
    51 =>"Regular Pay Overtime Pay Vacation Pay Holiday Pay", 
    52 =>"", 
    53 =>"32.000 4.000 8.000 0.000", 
    54 =>"", 
    55 =>"416.00 78.00 104.00 0.00", 
    56 =>"", 
    57 =>"16892.65 212.55 728.00 520.00", 
    58 =>"", 
    59 =>"Federal Income Medicare Tax FICA Tax ****** Income ************8 Non Res Hth Ins. Co-Pay Dental Co-Pay", 
    60 =>"", 
    61 =>"51.97 8.34 35.67 22.02 4.17 20.63 2.00", 
    62 =>"", 
    63 =>"1518.43 255.29 1091.79 657.53 126.91 679.12 65.48", 
    64 =>"", 
    65 =>"598.00", 
    66 =>"CURRENT EARNINGS", 
    67 =>"", 
    68 =>"144.80", 
    69 =>"CURRENT DEDUCTIONS", 
    70 =>"", 
    71 =>"453.20", 
    72 =>"NET PAY", 
    73 =>"", 
    74 =>"18353.20", 
    75 =>"Y.T.D. EARNINGS", 
    76 =>"", 
    77 =>"4394.55", 
    78 =>"Y.T.D. DEDUCTIONS", 
    79 =>"", 
    80 =>"13958.65", 
    81 =>"Y.T.D. NET PAY", 
    82 =>"", 
    83 =>". . . . . . . . . . ********************8", 
    84 =>"DATE AMOUNT", 
    85 =>"", 
    86 =>"09/04/2009", 
    87 =>"", 
    88 =>"$568.29", 
    89 =>"", 
    90 =>"PAY", 
    91 =>"", 
    92 =>"FIVE HUNDRED SIXTY EIGHT DOLLARS and 29 CENTS", 
    93 =>"", 
    94 =>"TO THE ORDER OF", 
    95 =>"", 
    96 =>"D************************** ******", 
    97 =>"", 
    98 =>"Bank Routing No.", 
    99 =>"", 
    100 =>"Bank Account Number", 
    101 =>"", 
    102 =>"Deposit Amount", 
    103 =>"", 
    104 =>"*********", 
    105 =>"", 
    106 =>"********8", 
    107 =>"", 
    108 =>"568.29", 
    109 =>"", 
    110 =>"NON NEGOTIABLE", 
    111 =>"9850", 
    112 =>"EMPLOYEE NO.", 
    113 =>"", 
    114 =>"01", 
    115 =>"SHIFT", 
    116 =>"", 
    117 =>"MIC", 
    118 =>"LOCATION HRS/UNITS", 
    119 =>"", 
    120 =>"************8", 
    121 =>"EMPLOYEE NAME CURRENT AMOUNT YEAR TO DATE", 
    122 =>"", 
    123 =>"08/30/2009", 
    124 =>"PERIOD END", 
    125 =>"", 
    126 =>"EARNINGS", 
    127 =>"", 
    128 =>"DEDUCTIONS", 
    129 =>"", 
    130 =>"CURRENT AMOUNT", 
    131 =>"", 
    132 =>"YEAR TO DATE", 
    133 =>"", 
    134 =>"Regular Pay Overtime Pay Vacation Pay Holiday Pay", 
    135 =>"", 
    136 =>"40.000 5.000 0.000 0.000", 
    137 =>"", 
    138 =>"680.00 127.50 0.00 0.00", 
    139 =>"", 
    140 =>"22525.29 1197.23 1020.00 680.00", 
    141 =>"", 
    142 =>"Federal Income Medicare Tax FICA Tax ******8 Income S****** Non Res Hth Ins. Co-Pay Dental Co-Pay", 
    143 =>"", 
    144 =>"97.28 11.06 47.30 33.18 5.72 40.67 4.00", 
    145 =>"", 
    146 =>"2915.90 346.23 1480.82 1038.98 179.03 1401.68 137.10", 
    147 =>"", 
    148 =>"807.50", 
    149 =>"CURRENT EARNINGS", 
    150 =>"", 
    151 =>"239.21", 
    152 =>"CURRENT DEDUCTIONS", 
    153 =>"", 
    154 =>"568.29", 
    155 =>"NET PAY", 
    156 =>"", 
    157 =>"25422.52", 
    158 =>"Y.T.D. EARNINGS", 
    159 =>"", 
    160 =>"7499.74", 
    161 =>"Y.T.D. DEDUCTIONS", 
    162 =>"", 
    163 =>"17922.78", 
    164 =>"Y.T.D. NET PAY", 
    165 =>"", 
    166 =>""
);

$employee = $x[array_search("EMPLOYEE NO.", $x)-1];
echo "Employee number: ".$employee."<br>";
?>

Was This Post Helpful? 0
  • +
  • -

#10 JordanH  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 46
  • Joined: 28-February 09

Re: Search array for values from database

Posted 18 October 2010 - 09:10 AM

View PostCTphpnwb, on 18 October 2010 - 07:30 AM, said:

If it's not the same index each time, then you were on the right track with array_search, but you need to search for something that will not change for each file. The ID will change, but hopefully "EMPLOYEE NO." will not.

<?php
$x = Array
(
    0 =>". . . . . . . . . . *********************************", 
    1 =>"DATE AMOUNT", 
    2 =>"", 
    3 =>"09/04/2009", 
    4 =>"", 
    5 =>"$453.20", 
    6 =>"", 
    7 =>"PAY", 
    8 =>"", 
    9 =>"FOUR HUNDRED FIFTY THREE DOLLARS and 20 CENTS", 
    10 =>"", 
    11 =>"TO THE ORDER OF", 
    12 =>"", 
    13 =>"********** ****************** ***********", 
    14 =>"", 
    15 =>"Bank Routing No.", 
    16 =>"", 
    17 =>"Bank Account Number", 
    18 =>"", 
    19 =>"Deposit Amount", 
    20 =>"", 
    21 =>"******", 
    22 =>"", 
    23 =>"******", 
    24 =>"", 
    25 =>"*****", 
    26 =>"", 
    27 =>"NON NEGOTIABLE", 
    28 =>"9871", 
    29 =>"EMPLOYEE NO.", 
    30 =>"", 
    31 =>"01", 
    32 =>"SHIFT", 
    33 =>"", 
    34 =>"MIC", 
    35 =>"LOCATION HRS/UNITS", 
    36 =>"", 
    37 =>"**************", 
    38 =>"EMPLOYEE NAME CURRENT AMOUNT YEAR TO DATE", 
    39 =>"", 
    40 =>"08/30/2009", 
    41 =>"PERIOD END", 
    42 =>"", 
    43 =>"EARNINGS", 
    44 =>"", 
    45 =>"DEDUCTIONS", 
    46 =>"", 
    47 =>"CURRENT AMOUNT", 
    48 =>"", 
    49 =>"YEAR TO DATE", 
    50 =>"", 
    51 =>"Regular Pay Overtime Pay Vacation Pay Holiday Pay", 
    52 =>"", 
    53 =>"32.000 4.000 8.000 0.000", 
    54 =>"", 
    55 =>"416.00 78.00 104.00 0.00", 
    56 =>"", 
    57 =>"16892.65 212.55 728.00 520.00", 
    58 =>"", 
    59 =>"Federal Income Medicare Tax FICA Tax ****** Income ************8 Non Res Hth Ins. Co-Pay Dental Co-Pay", 
    60 =>"", 
    61 =>"51.97 8.34 35.67 22.02 4.17 20.63 2.00", 
    62 =>"", 
    63 =>"1518.43 255.29 1091.79 657.53 126.91 679.12 65.48", 
    64 =>"", 
    65 =>"598.00", 
    66 =>"CURRENT EARNINGS", 
    67 =>"", 
    68 =>"144.80", 
    69 =>"CURRENT DEDUCTIONS", 
    70 =>"", 
    71 =>"453.20", 
    72 =>"NET PAY", 
    73 =>"", 
    74 =>"18353.20", 
    75 =>"Y.T.D. EARNINGS", 
    76 =>"", 
    77 =>"4394.55", 
    78 =>"Y.T.D. DEDUCTIONS", 
    79 =>"", 
    80 =>"13958.65", 
    81 =>"Y.T.D. NET PAY", 
    82 =>"", 
    83 =>". . . . . . . . . . ********************8", 
    84 =>"DATE AMOUNT", 
    85 =>"", 
    86 =>"09/04/2009", 
    87 =>"", 
    88 =>"$568.29", 
    89 =>"", 
    90 =>"PAY", 
    91 =>"", 
    92 =>"FIVE HUNDRED SIXTY EIGHT DOLLARS and 29 CENTS", 
    93 =>"", 
    94 =>"TO THE ORDER OF", 
    95 =>"", 
    96 =>"D************************** ******", 
    97 =>"", 
    98 =>"Bank Routing No.", 
    99 =>"", 
    100 =>"Bank Account Number", 
    101 =>"", 
    102 =>"Deposit Amount", 
    103 =>"", 
    104 =>"*********", 
    105 =>"", 
    106 =>"********8", 
    107 =>"", 
    108 =>"568.29", 
    109 =>"", 
    110 =>"NON NEGOTIABLE", 
    111 =>"9850", 
    112 =>"EMPLOYEE NO.", 
    113 =>"", 
    114 =>"01", 
    115 =>"SHIFT", 
    116 =>"", 
    117 =>"MIC", 
    118 =>"LOCATION HRS/UNITS", 
    119 =>"", 
    120 =>"************8", 
    121 =>"EMPLOYEE NAME CURRENT AMOUNT YEAR TO DATE", 
    122 =>"", 
    123 =>"08/30/2009", 
    124 =>"PERIOD END", 
    125 =>"", 
    126 =>"EARNINGS", 
    127 =>"", 
    128 =>"DEDUCTIONS", 
    129 =>"", 
    130 =>"CURRENT AMOUNT", 
    131 =>"", 
    132 =>"YEAR TO DATE", 
    133 =>"", 
    134 =>"Regular Pay Overtime Pay Vacation Pay Holiday Pay", 
    135 =>"", 
    136 =>"40.000 5.000 0.000 0.000", 
    137 =>"", 
    138 =>"680.00 127.50 0.00 0.00", 
    139 =>"", 
    140 =>"22525.29 1197.23 1020.00 680.00", 
    141 =>"", 
    142 =>"Federal Income Medicare Tax FICA Tax ******8 Income S****** Non Res Hth Ins. Co-Pay Dental Co-Pay", 
    143 =>"", 
    144 =>"97.28 11.06 47.30 33.18 5.72 40.67 4.00", 
    145 =>"", 
    146 =>"2915.90 346.23 1480.82 1038.98 179.03 1401.68 137.10", 
    147 =>"", 
    148 =>"807.50", 
    149 =>"CURRENT EARNINGS", 
    150 =>"", 
    151 =>"239.21", 
    152 =>"CURRENT DEDUCTIONS", 
    153 =>"", 
    154 =>"568.29", 
    155 =>"NET PAY", 
    156 =>"", 
    157 =>"25422.52", 
    158 =>"Y.T.D. EARNINGS", 
    159 =>"", 
    160 =>"7499.74", 
    161 =>"Y.T.D. DEDUCTIONS", 
    162 =>"", 
    163 =>"17922.78", 
    164 =>"Y.T.D. NET PAY", 
    165 =>"", 
    166 =>""
);

$employee = $x[array_search("EMPLOYEE NO.", $x)-1];
echo "Employee number: ".$employee."<br>";
?>


Ah, I see so once we find EMPLOYEE NO. we jump back one index and there is our employee ID...much simpler.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1