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 8813211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:47:25+00:00 2026-06-14T03:47:25+00:00

I’m trying to write an array or object to a file in plain-text (Not

  • 0

I’m trying to write an array or object to a file in plain-text (Not Binary), however whenever I loop over the array and look at the file I’m receiving Binary instead.

$this->user and $this->temp_files['in_file_name'] are passed into the function prior.

$user_array = (array)$this->user;
$data = "";

foreach ($user_array as $key => $value) {
    $data .= "$key $value\n";
}

file_put_contents($this->temp_files['in_file_name'], $data);

If i just pass a string into $data it gets written to the file as plain-text, but when I loop over the object or array I receive binary. Is there a way to get the plain-text version of this array in the file?

$this->user is a database row as an object from Ion_Auth called by:

$this->user =$this->ion_auth->user($this->user_id)->row();

Here is a portion of the output of the file

4461 7465 2054 7565 7364 6179 204f 6374 6f62 6572 2033 302c 2032 3031 3269 6420 320a 6970 5f61 6464 7265 7373 207f 0000 010a 7573 6572 6e61 6d65 2062 7261 6e64 6f6e 2062 6f73 7765 6c6c 0a70 6173 7377 6f72 6420 6539 3936 3630 6665 3039 3535 6663 3862 3431 6639 3838 3066 3639 6131 6664 6635

The var_dump of the user array is: (I’ve changed some values for data security reasons)

array (size=22)
  'id' => string '2' (length=1)
  'ip_address' => string '��' (length=4)
  'username' => string 'brandon' (length=15)
  'password' => string 'changed' (length=40)
  'salt' => null
  'email' => string 'brandon@changed.net' (length=27)
  'activation_code' => null
  'forgotten_password_code' => null
  'forgotten_password_time' => null
  'remember_code' => string 'changed' (length=40)
  'created_on' => string '1337702147' (length=10)
  'last_login' => string '1351607850' (length=10)
  'active' => string '1' (length=1)
  'first_name' => string 'Brandon' (length=7)
  'last_name' => string 'changed' (length=7)
  'company' => string 'changed' (length=17)
  'phone' => string '804-814-changed' (length=12)
  'store' => string 'mechanicsville' (length=14)
  'delivery' => string '1' (length=1)
  'receiveEmails' => string '1' (length=1)
  'customerType' => string 'business' (length=8)
  'user_id' => string '2' (length=1)

If I do a file_get_contents on the file it can be echoed back in correctly, but I wish the file were stored as plain-text.

  • 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-14T03:47:26+00:00Added an answer on June 14, 2026 at 3:47 am

    Decoding the hex bytes that you’ve posted reveals the correct data. So I’ll take a guess: PHP is writing the file perfectly, but the raw null bytes in the IP address (127.0.0.1) are confusing the OS or editor you are using to open the file, into thinking that this is not a text file, so it’s displaying it in a hex editor view for you. Try opening the file in a different editor, or saving the 'ip_address' field as text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.