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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:52:01+00:00 2026-06-11T19:52:01+00:00

After all I’m sorry for my English. I’m writing a script in PHP and

  • 0

After all I’m sorry for my English.

I’m writing a script in PHP and I encountered a small problem.

The idea is to create an array per line of text and replace the fourth value with a string representing the status.

I have a line of text e.g.
2022,33422,0,1,0,22

With a single line it works to create the array, but with multiple lines it creates an unexpected result.

Example:

2022,33422,0,1,0,22

2024,3232,01,1,04,298762

        $myArray = explode(',', $uploadServer);
        $status = array(0  => "Unprocessed",
                 1  => "Processing",
                 2  => "Download aborted because the file became too big.",
                 3  => "Download aborted because the file downloaded too long.",
                 4  => "Download finished. Uploading to RapidShare.",
                 5  => "Upload to RapidShare finished. Job finished.",
                 7  => "Upload failed 3 times for unknown reasons. Job aborted.",
                 8  => "Upload failed because the file is black listed.",
                 9  => "Download failed for unknown reasons.",
                 11 => "Enqueued for later processing because this account already downloads 5 files at the same time.");



        foreach ($myArray as $valor) {
              if(array_key_exists($valor[3],$status)) {

                    return $passer[] = $status[$valor[3]];

              } else {

                    return FALSE;

              }
        }

The result of $myArray is

Array
(
    [0] => 2022
    [1] => 33422
    [2] => 0
    [3] => 1
    [4] => 0
    [5] => 22
)

But I need this final array

Array
(
[0]=>array(
          [0] => 2022
          [1] => 33422
          [2] => 0
          [3] => Processing
          [4] => 0
          [5] => 22
          )

[1]=>array(
           [0] => 2022
           [1] => 33422
           [2] => 0
           [3] => Processing
           [4] => 0
           [5] => 22
          )
)

Any idea?
thanks

  • 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-11T19:52:02+00:00Added an answer on June 11, 2026 at 7:52 pm

    UPDATE: So you have a string with a linebreak in it. This linebreak is an invisible character (\n). First split your string on every linebreak. Then loop through this array. split the strings on every comma and change the value with index 3:

    $myArray = explode("\n", $uploadServer);
    
    $status = array(0  => "Unprocessed",
                 1  => "Processing",
                 2  => "Download aborted because the file became too big.",
                 3  => "Download aborted because the file downloaded too long.",
                 4  => "Download finished. Uploading to RapidShare.",
                 5  => "Upload to RapidShare finished. Job finished.",
                 7  => "Upload failed 3 times for unknown reasons. Job aborted.",
                 8  => "Upload failed because the file is black listed.",
                 9  => "Download failed for unknown reasons.",
                 11 => "Enqueued for later processing because this account already downloads 5 files at the same time.");
    
    $passer = array(); //create array to fill
    foreach( $myArray as $valor ) { //loop through lines
       if( !empty($valor) ) { // check for empty line
         $tmp = explode(',', $valor);  //make array of strings
         if(array_key_exists($tmp[3],$status)) {  //check value [3]
           $tmp[3] = $status[$tmp[3]];
         }     
         $passer[] = $tmp;   //append array to parent array
      } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a selenium script that should only start testing after all ajax calls
It is Hallowe'en after all. Here's the problem: I'm maintaining some old-ish J2EE code,
I have like 50 different php files which all use the mail function. After
Is there an event that is triggered after all Page_Load events have completed? How
How do I execute my custom code after all normal processing associated to changing
How do I get a function to run after all the fadeOuts in the
Is it possible to have one jQuery ready block executed after all others have
I read a lot of links and suggestions and after all I'm even more
SBT has a nice hook which allows you to execute arbitrary code after all
I have recently upgraded my MVC 3 project to MVC 4. After all the

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.