Jump to content

Search the Community

Showing results for tags 'phpexplode'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi guys, Users of my website will be copying and pasting their work schedule from another website that displays it in a html table, as shown below, in to a textarea on my website which I can then decode and store in a mysql db. To do this I am trying to put every value in to an array with the associated column name/key. |Date| |Duty| |Dep| |Start| |End| |Arr| 4 Apr 14, Fri 3005 (Z) CIA 04:15 Z 07:05 Z STN 4 Apr 14, Fri 3002 STN 07:45 Z 10:15 Z CIA 5 Apr 14, Sat OFF (Z) CIA 00:00 Z 21:00 Z The small problem being both the 'Duty' and 'Arr' column can have any numerical, text or blank spaces in them. All the other columns have the same format in every row. (such as the 'Dep' column is always 3 uppercase characters etc). I have tried to separate the parts of each line as you can see in the code below but this would not be consistent due to the extra spaces the sometimes occur in the 'Duty' column. Does anyone see a way to make this fault proof?! Thanks <?php $lines = explode("\n", $_POST['test']); $sector = 1; foreach($lines as $line) { if(substr($line, 0, 4)=='Date') { //Skip header line continue; } $parts = preg_split('/\s+/', $line); echo 'Sector '.$sector.'<br />'; $date = $parts[0] . '/' . $parts[1] . '/20' . trim($parts[2], ','); $duty = $parts[4]; $dep = $parts[5]; $begin = $parts[6]; $end = $parts[8]; $arr = $parts[10]; $sector++; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.