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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:08:12+00:00 2026-05-31T09:08:12+00:00

I have this issue i am writing a array to a file but when

  • 0

I have this issue i am writing a array to a file but when i unset() some sub arrays it keeps the comma or when i add anther sub array to the end it add a comma.

eg:

$account_data = include('./*****/AccountData.php');

$account_data[$username]['Name']     = $name;
$account_data[$username]['Password'] = $password;
$account_data[$username]['RandID']   = $randid;
$account_data[$username]['PublicD']  = $publicdownload;
$account_data[$username]['Enabled']  = $enabled;
$account_data[$username]['Admin']    = $admin;

$configdata = "<?php\n\nreturn ".var_export($account_data, true)."; \n\n?>";

$file = fopen('./*****/AccountDataTest.php', 'w');
fwrite($file, $configdata);
fclose($file);

when i run that code to add a sun array i get this

<?php
return array (
    'Ryan' => array (
        'Name' => 'Ryan',
        'Password' => '',
        'RandID' => '',
        'PublicD' => 0,
        'Enabled' => 1,
        'Admin' => 0,
    ),
    'Chris' => array (
        'Name' => 'Christopher',
        'Password' => '',
        'RandID' => '',
        'PublicD' => 1,
        'Enabled' => 1,
        'Admin' => 1,
    ),
);
?>

as you can see it adds a comma and when i run my unset function the code for the AccountData.php file will look the same with out the Chris but it has the following comma at the end of Ryan.

I am not sure how I can fix this I have been googling with not much luck.

  • 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-05-31T09:08:13+00:00Added an answer on May 31, 2026 at 9:08 am

    I’m not sure if I understand the problem, but you would probably save yourself a lot of headaches by using serialize and unserialize to save your data in a file.

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

Sidebar

Related Questions

I do not currently have this issue , but you never know, and thought
I have been having this issue in iterating through an array of keys and
I know this issue has been touched on here but I have not found
I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
I have this strange issue with my web app. You see, I'm using jQuery
I have this exact issue ASP.net can’t update page from event handler and it's
I have this chronic issue with iPhone UI development where views sometimes seem to
Continuing my problem from yesterday, the Silverlight datagrid I have from this issue is
I am having trouble with the following SQL statement. I have had this issue
Note: This issue appears to be limited to SQL Server 2005 SP2 I have

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.