Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:16:04+00:00 2026-06-09T06:16:04+00:00

I’m writing a module that is supposed to be able to export transaction records

  • 0

I’m writing a module that is supposed to be able to export transaction records in BankOne format.

Here is the specification of the format

Here is an example file

The fields are put in specific ranges on the line and records are seperated by new lines. Lots of spaces needs to be added to ensure that the fields start and end at specific points in the line.

I wrote a function in php for this. It takes in the fields as parameters and should return a properly formatted record.

function record4($checknum='', $nameid='', $purpose='', $pledge='', $payment='', 
             $frequency='', $title='', $fname='', $lname='', $suffix='',
             $address='', $postalcode='', $city='', $state='', $greeting='')
{
$fields = array(
    'checknum' => array('length' => 8, 'start' => 37),
    'nameid' => array('length' => 7, 'start' => 45),
    'purpose' => array('length' => 5, 'start' => 52),
    'pledge' => array('length' => 10, 'start' => 57),
    'payment' => array('length' => 10, 'start' => 67),
    'frequency' => array('length' => 1, 'start' => 77),
    'title' => array('length' => 20, 'start' => 78),
    'fname' => array('length' => 40, 'start' => 98),
    'lname' => array('length' => 40, 'start' => 138),
    'suffix' => array('length' => 20, 'start' => 178),
    'address' => array('length' => 35, 'start' => 198),
    'postalcode' => array('length' => 10, 'start' => 233),
    'city' => array('length' => 28, 'start' => 243),
    'state' => array('length' => 5, 'start' => 271),
    'greeting' => array('length' => 40, 'start' => 276)
);

$str = '4';
foreach($fields as $field_name => $field)
{
    if($$field_name)
    {
        $str = str_pad($str, $field['start']-1, ' ');
        $str = $str.substr(trim((string)$$field_name), 0, $field['length']);
    }
}

return $str."\n";
}

It seems to work as intended, but when I looked at the output file I found this (scroll to the end):

4                                                                 1                              David                                   Landrum
4                                                                 3                              Hazel                                   Baker
4                                                                 3                              Jerome                                  Zehnder
4                                                                 1                              Víctor                               Nadales
4                                                                 2                              Philip                                  Nauert
4                                                                 1                              Jana                                    Ortcutter

The file contains 900 records pulled from a database, all of them are formatted correctly, except Víctor Nadales. After that first name, every other field is three spaces left of where it is supposed to be. The only anomalous thing about this record appears to be the ‘Ã’ in the first name.

The function is supposed to pad out the string to the proper length after each and every field it processes, yet it somehow gets fooled on this one line?

Can anyone tell me what is going on here?

EDIT: I just realized that whatever imports files of this format might not even support special UTF-8 characters. Therefore I added this line to my code:

$$field_name = iconv('UTF-8', 'ASCII//TRANSLIT', $$field_name);

The à comes out looking like this: ~A-. Not ideal, but at least the file is formatted properly now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:16:05+00:00Added an answer on June 9, 2026 at 6:16 am

    This is happening because 'Ã' is a multi-byte character (4 bytes long), and str_pad is counting bytes rather than logical characters.

    This is why you are missing three spaces, str_pad is counting 'Ã' as 4 single byte characters instead of one multi-byte one.

    Try this function (credit here).

    <?
    function mb_str_pad( $input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT)
    {
        $diff = strlen( $input ) - mb_strlen( $input );
        return str_pad( $input, $pad_length + $diff, $pad_string, $pad_type );
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.