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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:50:48+00:00 2026-05-25T22:50:48+00:00

I know this might ma a simple question, it must have been answered before

  • 0

I know this might ma a simple question, it must have been answered before but it’s the kind of question you don’t know how to google for.

I’m doing an intranet and I have a big texarea in wich te user pastes a 5columns X 365 rows (an optional first column with the 1 to 365 numbers) from excel and ends up in this:

1   $ 37    $ 74    $ 111   $ 148   $ 185
2   $ 37    $ 74    $ 111   $ 148   $ 185
3   $ 37    $ 74    $ 111   $ 148   $ 185
4   $ 37    $ 74    $ 111   $ 148   $ 185
5   $ 37    $ 74    $ 111   $ 148   $ 185
6   $ 57    $ 114   $ 171   $ 228   $ 285
7   $ 57    $ 114   $ 171   $ 228   $ 285
8   $ 57    $ 114   $ 171   $ 228   $ 285
9   $ 57    $ 114   $ 171   $ 228   $ 285
10  $ 57    $ 114   $ 171   $ 228   $ 285

How can I turn this into a php array so I can then insert it into a mysql table?
I tought about using explode() but I’m not sure if the space between each column will always be the same, maybe there’s a fancier way to do this.

If this is already discussed somewhere else just point me to it.

Thanks a lot

  • 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-25T22:50:49+00:00Added an answer on May 25, 2026 at 10:50 pm

    Explode per ligne '\n' and then per column '\t' and just ignore the $

    <?php
    $str = "    1   $ 37    $ 74    $ 111   $ 148   $ 185
        2   $ 37    $ 74    $ 111   $ 148   $ 185
        3   $ 37    $ 74    $ 111   $ 148   $ 185
        4   $ 37    $ 74    $ 111   $ 148   $ 185
        5   $ 37    $ 74    $ 111   $ 148   $ 185
        6   $ 57    $ 114   $ 171   $ 228   $ 285
        7   $ 57    $ 114   $ 171   $ 228   $ 285
        8   $ 57    $ 114   $ 171   $ 228   $ 285
        9   $ 57    $ 114   $ 171   $ 228   $ 285
        10  $ 57    $ 114   $ 171   $ 228   $ 285";
    
    
    $arrayCode = array();
    $rows = explode("\n", $str);
    foreach($rows as $idx => $row)
    {
        $row = explode( "\t", $row );
    
        //to get rid of first item (the number)
        //comment it if you don't need.
        array_shift ( $row );
    
        foreach( $row as $field )
        {
            //to clean up $ sign
            $field = trim( $field, "$ ");
            $arrayCode[$idx][] = $field;
        }
    }
    print_r( $arrayCode );
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this might be really a simple question but I don't know the
I know this might be a simple question but I have to make sure
This might be a simple question, but I'll ask it anyways. I know when
This might be a simple question for those who know Spring, but since I
This might be a simple question.but,does any one know how to disable a button
I'm new to serialization, so this might be a simple question, but my google-fu
This might seem like a simple question but Id like to know the fastest
I know this might a simple question, but is there a way to add
I know this might seem a simple question, but with all the WMD versions
I know this might be very easy to some,, I have a simple string

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.