i have multiple users who need to update a table into mysql with a csv file they will need to do this by pasting the csv file into a text area on the website
the first row of that file contains the name of each feild and i need to get rid of that plus i also need to add
the user name to each rows (so i know who the user is for each row) and finaly i need to get rid of the last row of the csv file too (and the file dont have the same amount of rows)

ill paste you a bit of the file so you understand better

Id Name Position Reference city guards ballistas rangers guardians templars berserkers mages scouts crossbowmen paladins knights warlocks rams catapults frigates sloops war galleons barons TS Summary (dbl click to select)
"27132364" "Landingzone" "'460:414" "" "487" "0" "0" "0" "0" "1993" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "1993" "487 city guards, 1993 berserkers"
"27263434" "valcartier" "'458:416" "" "0" "0" "24411" "12354" "0" "24837" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "61602" "24411 rangers, 12354 guardians, 24837 berserkers"
"26935754" "Magog" "'458:411" "" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "24" "0" "0" "2400" "24 sloops"
"Total" "Total" "'" "" "487" "0" "24411" "12354" "0" "26971" "0" "0" "0" "0" "0" "0" "0" "0" "0" "24" "0" "1" "66137" "487 city guards, 24411 rangers, 12354 guardians, 26971 berserkers, 24 sloops, 1 baron"

as you see the feild are delimited by double quote and i have no clue how the row change is made i am really lost here any help would be welcomed ty

Recommended Answers

All 34 Replies

Please don't ask anyone to write the whole script for you. Try to solve it yourself, then let us know where you're having trouble. Here are a few hints:

  • Look up PHP file input functions (fopen(), fgetcsv(), file(), str_getcsv()) -- several of these may be handy.
  • If you have an array of the file contents where each index is a row from the CSV, the first index will be the column headers. You can skip this row (i.e., skip $myArray[0]).
  • To determine the last row, there are a number of methods:

    • If you are using PHP 5.3 you can use str_getcsv( end( $myArray), ',', '"')
    • Otherwise, store each line as you loop through the array. After you leave the array, the item left in your variable will be the last line.

i have no clue how the row change is made

A row change should be indicated by a new line.

i have read all of that documentation before i made my post and i never asked anyone to write the whole thing for me i was looking for a start point something i could work with that would let me understand what i am dealing with not an answer a google search would give me but ty anyway

Member Avatar for diafol

I think it's fair to say EF has given you good tips and a pretty good starting point. Have a play with it and come back with an attempt so that we can help you with it.

if you guys had even bother to read my question you would have noticed why fgetcsv fonction doesnt work.... my feilds are seperated by double quotes not a coma so instead of having this data1,data2
you have this ''data1'' ''data2'' changing the separator wont work ii know i had tried before i even got to this forum another details if i kne how to code this if i had that much knowledge i wouldnt be here to ask for help but rest assure with that kind of attitude chances are i wont be back to often

@jethaya, I'm sorry if you think I was being hostile. Usually it's accepted that someone asking a question will provide the code that is giving them problems. You say you already tried some things, so why not show us your code. If you had, we could try to point out any mistakes. Especially when you say you're not very experienced in PHP, that reinforces the need for us to see the code.

Further, saying "if you guys had even bother to read my question..." seems rather ironic. If you had read the PHP documentation a little more closely, you'd see that the fourth parameter for fgetcsv() and the third parameter for str_getcsv() accepts a charcter for indicating the enclosure. Now, you may not know what the term "enclosure" refers to, but if you had read the code that I posted, you'd see I accounted for the double quotation marks on this line in the third parameter for str_getcsv():

If you are using PHP 5.3 you can use str_getcsv( end( $myArray), ',', '"')

All you have to do above is change the comma (,) in the delimeter parameter to a space ( ). Also, if you had posted your code, we could have seen right away if you were missing this parameter.

rest assure with that kind of attitude chances are i wont be back to often

No one here is getting paid to assist you. We do this because we like to help and solve problems. If you think about it, it's inconsiderate to come on here and waste the time of people who are trying to give you free assistance. I was not giving you "attitude", rather just trying to get to the heart of the issue. Hence my follow-up points on what to look into.

** If you think about it, it's inconsiderate to come on here and waste the time of people who are trying to give you free assistance**

i am really sorry for having wasted your time dont worry it wont happen again

fortunatly there is other forum where peoples dont mind wasting a litle time. helping newcommers who know less they they do

all it took to help me was 3 lines of code with a 4 lines explanation

your first answer would have been fine for a consumate php programmer but if you read my initial post its not hard to figure out that i am not
so trowing me a bunch of php function or a line of code with a few parameter isnt helping

and if you think saying ''Please don't ask anyone to write the whole script for you.'' isnt giving attitude your wrong

as for the futur maybe you should add a ''we dont help beginners '' in your FAQ

Member Avatar for LastMitch

if you guys had even bother to read my question you would have noticed why fgetcsv fonction doesnt work.... my feilds are seperated by double quotes not a coma so instead of having this data1,data2you have this ''data1'' ''data2'' changing the separator wont work ii know i had tried before i even got to this forum another details if i kne how to code this if i had that much knowledge i wouldnt be here to ask for help but rest assure with that kind of attitude chances are i wont be back to often

I mean I usually don't or even try to jump in this kind of an issue but how can any members read this and understand what you are doing:

Id Name Position Reference city guards ballistas rangers guardians templars berserkers mages scouts crossbowmen paladins knights warlocks rams catapults frigates sloops war galleons barons TS Summary (dbl click to select)
"27132364" "Landingzone" "'460:414" "" "487" "0" "0" "0" "0" "1993" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "1993" "487 city guards, 1993 berserkers"
"27263434" "valcartier" "'458:416" "" "0" "0" "24411" "12354" "0" "24837" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "61602" "24411 rangers, 12354 guardians, 24837 berserkers"
"26935754" "Magog" "'458:411" "" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "24" "0" "0" "2400" "24 sloops"
"Total" "Total" "'" "" "487" "0" "24411" "12354" "0" "26971" "0" "0" "0" "0" "0" "0" "0" "0" "0" "24" "0" "1" "66137" "487 city guards, 24411 rangers, 12354 guardians, 26971 berserkers, 24 sloops, 1 baron"

You got the code from here:

http://pastebin.com/Q0v28x2Z

But you rush into this by just copying and paste without even bother make it more presentable.

You expect someone to guide or give you an direction base on what you post (it's just gibberish data not a code)?

And you actually think someone can read your mind (code) and see what you are doing (how you got that error and why it's not working)?

What EF mention is a correct response base on what you post and diafol also suggestion to look into it.

You can't say noone is helping you and not reading what you wrote.

You should consisted yourself lucky to have 2 responses and getting attention.

You should feel glad and thankful that a Daniweb members is helping you.

If you were on stackoverflow and other forums most likely your thread will not get any replies nor a answer (guide) base on what you post and you might also get negative responses.

The reason it's not organized and presentable and you are not very clear what you are trying to do.

Member Avatar for diafol

@jethaya

We are always here to help. We are still prepared to help you, even though you seem to have taken our advice or comments as a personal rebuke. As Lastmitch states, certain other forums would have given you both barrels for the first post, but EF DID help you with starting points. If you read the 'Rules', you'll see that it clearly states that you should show evidence of some work yourself. Where this is not possible, as you don't have an idea where to start, then some info as to where you can get ideas in order to help yourself, seems an appropriate response.

It is more productive for all concerned if we can concentrate on improving provided code rather than rehashing the php manual examples. I sincerely hope that you change your mind and enjoy becoming a regular visitor.

diafol.

to be honest i got insulted when i was told not to ask for someone to write the whole thing for me
and it went down hill after that
this thing will have hundreds of line of code when ill be done with it
and all i was asking was how to get a file pasted into a txtarea into my database

so this is where i am at

$array_csv = str_getcsv( end($_POST["textArea1"]), '', '"');

now i think this should read my text area and parse it into $array_csv
2 questions
a: do this need to be in a while loop? to read all the rows or is the whole file in there into a single string
b: EvolutionFallen putted a (end) in front of the variable containing the csv file what does this do?

jethaya

i am still working on it i am getting closer i am able to get my file parsed but i dont get the result i was expecting this is my code

<?php

$line = $_POST["textArea1"];
$parsed = str_getcsv(
    $line, # Input line
    ' ',   # Delimiter
    '"',   # Enclosure
    '\\'   # Escape char
);

var_dump( $parsed );

?>

this is the result i get

array(5) { [0]=> string(14) "15204609   "City" 
[1]=> string(2) "of"
[2]=> string(107) "Jethaya" "'257:232"  ""  "0" "0" "0" "0" "0" "163"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "163"   "163" 
[3]=> string(120) "berserkers" "Total"  "Total" "'" ""  "0" "0" "0" "0" "0" "163"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "163" "163" 
[4]=> string(11) "berserkers"" }

i should get two lines
line A) 15204609 ''city of jethaya '' ''257:232'' etc

line B should start with "Total" "Total" etc
ill paste below what is pasted in the textArea1

"15204609"  "City of Jethaya"   "'257:232"  ""  "0" "0" "0" "0" "0" "163"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "163"   "163 berserkers"
"Total" "Total" "'" ""  "0" "0" "0" "0" "0" "163"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "163"   "163 berserkers"

so i know i am not parsing it right my goal is to get each feild seperated by double quote in a separate var so i could upload them in my DB
where did i go wrong ? did i get the enclosure and the delimiter right ?

jethaya
so i should get two arrays one for each line ?

Member Avatar for diafol

OK a few things - you have multiple spaces in your pasted text, so these will insert 'empty fields' - ensure that all spaces are just singles. Also you need a loop. Here's a quick snippet to get you started.

<?php
if(isset($_POST['ta1'])){
    $str = $_POST['ta1'];
    $lines = explode("\n", $str);

    $parsedArray = array();
    foreach ($lines as $line) {
        $parsedArray[] = str_getcsv($line, ' ', '"', '\\');
    }
    echo "<pre>";
    print_r($parsedArray);
    echo "</pre>";
}
?>

<form method="post">
    <textarea name="ta1">"15204609" "City of Jethaya" "'257:232" "" "0" "0" "0" "0" "0" "163" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "163" "163 berserkers"
    "Total" "Total" "'" "" "0" "0" "0" "0" "0" "163" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "163" "163 berserkers"</textarea>
    <input type="submit" value="Parse" name="submit" />
</form>

diafol tank you for your help your code work nicely but when i substitute my textArea the result gets all mixed up even if i try to remove the space manualy from the text area so i think what i need to do is to find a way to only consider whats is inside the a pair of double quote to go in the array ignoring the spaces completely i dont even know if thats possible using str_getcsv

one thing is for sure i cant ask the user to take the spaces out :)
ill do some research i think i need a loop that will look for the first ('') puts everything in the first row of the array until it finds another ('')
then it will move to the next row looking for a ('') etc
until the end of that line of the string

Member Avatar for diafol

A traditional csv uses commas as a delimiter - so you could use that instead. You could then use a trim() function to strip extra spaces from the data. Else you could run a string replacement on the whole string to strip out multiple spaces, leaving just single ones.

Here's an example:

<?php
if(isset($_POST['ta1'])){
    $str = $_POST['ta1'];
    $str = preg_replace("/\s+/", ' ', $str); //this replaces multiple spaces with single space
    $lines = explode("\n", $str);
    //code as before
}
?>

this works all the spces are gone :) but when i add it to the rest of the code like this

<?php
if(isset($_POST['TextArea1'])){
    $str = $_POST['TextArea1'];
    $str = preg_replace("/\s+/", ' ', $str);
    $lines = explode("\n", $str);
    $parsedArray = array();
    foreach ($lines as $line) {
        $parsedArray[] = str_getcsv($line, ' ', '"', '\\');
    }
    echo "<pre>";
    print_r($parsedArray);
    echo "</pre>";
}
?>

it returns both line in the same array the line change got lost and the user will have multiple lines
not just two like in my test file ill see if i can find why the line change get lost tanks a lot

jethaya

Member Avatar for diafol

Ok, my mistake:

$str = preg_replace("/ +/", ' ', $str);

now i get this as result

Array
(
    [0] => Array
        (
            [0] => 15204609 "City
            [1] => of
            [2] => Jethaya" "'257:232"  ""  "0" "0" "0" "0" "0" "172"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "172"   "172
            [3] => berserkers"
        )

    [1] => Array
        (
            [0] => Total    "Total" "'" ""  "0" "0" "0" "0" "0" "172"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "172"   "172
            [1] => berserkers"
        )

    [2] => Array
        (
            [0] => 
        )

)

i will read up on regex i am sure this is real close the

ty

Member Avatar for diafol

Odd - I get this (correct):

Array
(
    [0] => Array
        (
            [0] => 15204609
            [1] => City of Jethaya
            [2] => '257:232
            [3] => 
            [4] => 0
            [5] => 0
            [6] => 0
            [7] => 0
            [8] => 0
            [9] => 163
            [10] => 0
            [11] => 0
            [12] => 0
            [13] => 0
            [14] => 0
            [15] => 0
            [16] => 0
            [17] => 0
            [18] => 0
            [19] => 0
            [20] => 0
            [21] => 0
            [22] => 163
            [23] => 163 berserkers
        )

    [1] => Array
        (
            [0] => 
            [1] => Total
            [2] => Total
            [3] => '
            [4] => 
            [5] => 0
            [6] => 0
            [7] => 0
            [8] => 0
            [9] => 0
            [10] => 163
            [11] => 0
            [12] => 0
            [13] => 0
            [14] => 0
            [15] => 0
            [16] => 0
            [17] => 0
            [18] => 0
            [19] => 0
            [20] => 0
            [21] => 0
            [22] => 0
            [23] => 163
            [24] => 163 berserkers
        )

)
Member Avatar for diafol

And I get this:

Array
(
    [0] => Array
        (
            [0] => 27132364
            [1] => Landingzone
            [2] => '460:414
            [3] => 
            [4] => 487
            [5] => 0
            [6] => 0
            [7] => 0
            [8] => 0
            [9] => 1993
            [10] => 0
            [11] => 0
            [12] => 0
            [13] => 0
            [14] => 0
            [15] => 0
            [16] => 0
            [17] => 0
            [18] => 0
            [19] => 0
            [20] => 0
            [21] => 0
            [22] => 1993
            [23] => 487 city guards, 1993 berserkers
        )

    [1] => Array
        (
            [0] => 27263434
            [1] => valcartier
            [2] => '458:416
            [3] => 
            [4] => 0
            [5] => 0
            [6] => 24411
            [7] => 12354
            [8] => 0
            [9] => 24837
            [10] => 0
            [11] => 0
            [12] => 0
            [13] => 0
            [14] => 0
            [15] => 0
            [16] => 0
            [17] => 0
            [18] => 0
            [19] => 0
            [20] => 0
            [21] => 0
            [22] => 61602
            [23] => 24411 rangers, 12354 guardians, 24837 berserkers
        )

    [2] => Array
        (
            [0] => 26935754
            [1] => Magog
            [2] => '458:411
            [3] => 
            [4] => 0
            [5] => 0
            [6] => 0
            [7] => 0
            [8] => 0
            [9] => 0
            [10] => 0
            [11] => 0
            [12] => 0
            [13] => 0
            [14] => 0
            [15] => 0
            [16] => 0
            [17] => 0
            [18] => 0
            [19] => 24
            [20] => 0
            [21] => 0
            [22] => 2400
            [23] => 24 sloops
        )

    [3] => Array
        (
            [0] => Total
            [1] => Total
            [2] => '
            [3] => 
            [4] => 487
            [5] => 0
            [6] => 24411
            [7] => 12354
            [8] => 0
            [9] => 26971
            [10] => 0
            [11] => 0
            [12] => 0
            [13] => 0
            [14] => 0
            [15] => 0
            [16] => 0
            [17] => 0
            [18] => 0
            [19] => 24
            [20] => 0
            [21] => 1
            [22] => 66137
            [23] => 487 city guards, 24411 rangers, 12354 guardians, 26971 berserkers, 24 sloops, 1 baron
        )

)

From:

"27132364" "Landingzone" "'460:414"    "" "487" "0" "0" "0" "0" "1993" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "1993" "487 city guards, 1993 berserkers"
"27263434" "valcartier" "'458:416" "" "0" "0" "24411" "12354" "0"    "24837" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "61602" "24411 rangers, 12354 guardians, 24837 berserkers"
"26935754" "Magog" "'458:411" "" "0" "0" "0" "0" "0" "0" "0" "0" "0"   "0" "0" "0" "0" "0" "0" "24" "0" "0" "2400" "24 sloops"
"Total" "Total" "'" "" "487" "0" "24411" "12354" "0" "26971" "0" "0" "0" "0" "0" "0" "0" "0" "0" "24" "0" "1" "66137" "487 city guards, 24411 rangers, 12354 guardians, 26971 berserkers, 24 sloops, 1 baron"
<?php
if(isset($_POST['TextArea1'])){
    $str = $_POST['TextArea1'];
    $str = preg_replace("/ +/", ' ', $str);
    $lines = explode("\n", $str);
    $parsedArray = array();
    foreach ($lines as $line) {
        $parsedArray[] = str_getcsv($line, ' ', '"', '\\');
    }
    echo "<pre>";
    print_r($parsedArray);
    echo "</pre>";
}
?>

when i use this code it doesnt work for me i veryfied 10 times could it be my php version on the server ? they are using 5.4 the result you have is exactly what i am looking for so it must be on my end ty for all the help i posted the code just in case i typed something wrong
Jethaya

Member Avatar for diafol

It seems the same as my code:

if(isset($_POST['ta1'])){
    $str = $_POST['ta1'];
    $str = preg_replace("/ +/", ' ', $str);
    $lines = explode("\n", $str);
    $parsedArray = array();
    foreach ($lines as $line) {
        $parsedArray[] = str_getcsv($line, ' ', '"', '\\');
    }
    echo "<pre>";
    print_r($parsedArray);
    echo "</pre>";
}
?>

I'm using 5.4 too. What's the output?

Post the input (what you paste into the textarea) and the resulting output please.

i was thinking it might have been my form that was doing something wrong so i did this

<?php
if(isset($_POST['TextArea1'])){
    $str = $_POST['TextArea1'];
    $str = preg_replace("/ +/", ' ', $str);
    $lines = explode("\n", $str);
    $parsedArray = array();
    foreach ($lines as $line) {
        $parsedArray[] = str_getcsv($line, ' ', '"', '\\');
    }
    echo "<pre>";
    print_r($parsedArray);
    echo "</pre>";
}
?>

<form method="post" >
 <textarea name="TextArea1" id="TextArea1" rows="10" cols="50"></textarea>

<input type="submit" value="Parse" name="submit" />
</form>


i get this  


Array
(
    [0] => Array
        (
            [0] => 15204609 "City
            [1] => of
            [2] => Jethaya" "'257:232"  ""  "0" "0" "0" "0" "0" "175"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "175"   "175
            [3] => berserkers"
        )

    [1] => Array
        (
            [0] => Total    "Total" "'" ""  "0" "0" "0" "0" "0" "175"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "175"   "175
            [1] => berserkers"
        )

    [2] => Array
        (
            [0] => 
        )

)

when i pasted in it i got the same result as before ill keep digging could it be the post method ? or the pasting ?

jethaya

sorry i had not see you post this is what was pasted

"City of Jethaya"   "'257:232"  ""  "0" "0" "0" "0" "0" "175"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "175"   "175 berserkers"
"Total" "Total" "'" ""  "0" "0" "0" "0" "0" "175"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "175"   "175 berserkers"
Member Avatar for diafol

You do realise that you have 22 items in the first record and 23 in the second?

788f79044cd7da1942b9e3ef93ce9f61

(click the thumb in the attachments box to see full size)

"15204609"  "City of Jethaya"   "'257:232"  ""  "0" "0" "0" "0" "0" "184"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "184"   "184 berserkers"
"Total" "Total" "'" ""  "0" "0" "0" "0" "0" "184"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "184"   "184 berserkers"

using this and the following code

<?php
if(isset($_POST['TextArea1'])){
    $str = $_POST['TextArea1'];
    $str = preg_replace("/ +/", ' ', $str);
    $lines = explode("\n", $str);
    $parsedArray = array();
    foreach ($lines as $line) {
        $parsedArray[] = str_getcsv($line, ' ', '"', '\\');
    }
    echo "<pre>";
    print_r($parsedArray);
    echo "</pre>";
}
?>
<form method="post" >
 <textarea name="TextArea1" id="TextArea1" rows="10" cols="50"></textarea>
<input type="submit" value="Parse" name="submit" />
</form>

i get this result

Array
(
    [0] => Array
        (
            [0] => 15204609 "City
            [1] => of
            [2] => Jethaya" "'257:232"  ""  "0" "0" "0" "0" "0" "184"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "184"   "184
            [3] => berserkers"
        )

    [1] => Array
        (
            [0] => Total    "Total" "'" ""  "0" "0" "0" "0" "0" "184"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "184"   "184
            [1] => berserkers"
        )

    [2] => Array
        (
            [0] => 
        )

)

i dont know why i get different results then you i even tried with a different browser

jeth

at the place you sent me to if i use the data you provide in the text area it works but if i try to substitute new data i get the same result i get on my server i tested it and made an integral copy of the code i found there it worked to on my server but when i replace the data it get the previous bad result

Array Index: 0

Array
(
    [0] => Id   Name    Position    Reference   city
    [1] => guards   ballistas   rangers guardians   templars    berserkers  mages   scouts  crossbowmen paladins    knights warlocks    rams    catapults   frigates    sloops  war
    [2] => galleons barons  TS  Summary
    [3] => (dbl
    [4] => click
    [5] => to
    [6] => select)
)
Array Index: 1

Array
(
    [0] => 15204609 "City
    [1] => of
    [2] => Jethaya" "'257:232"  ""  "0" "0" "0" "0" "0" "180"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "180"   "180
    [3] => berserkers"
)
Array Index: 2

Array
(
    [0] => Total    "Total" "'" ""  "0" "0" "0" "0" "0" "180"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "180"   "180
    [1] => berserkers"
)
Array Index: 3

Array
(
    [0] => 
)

i think this is due to this forum i have noticed it takes away some spaces when you compare where you type to where the text appear you can verify this by using your space bar when you type in the edit window the space you add dont appear below

"15204609"  "City of Jethaya"   "'257:232"  ""  "0" "0" "0" "0" "0" "180"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "180"   "180 berserkers"
"Total" "Total" "'" ""  "0" "0" "0" "0" "0" "180"   "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "180"   "180 berserkers"

"15204609" "City of Jethaya" "'257:232" "" "0" "0" "0" "0" "0" "180" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "180" "180 berserkers"
"Total" "Total" "'" "" "0" "0" "0" "0" "0" "180" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "0" "180" "180 berserkers"

see the difference ?

i just tried something i copy pasted the data fom the forum into my server form and it works
but when i use the raw data from the original copy paste it doesnt i joined a file with the data i pasted in note pad

jeth

Member Avatar for diafol

You have tabspaces between your values not spaces. THATS the problem.

ok so i tried using this

`$str = preg_replace("/ \t +/", ' ', $str);

to remove the tabspaces but it didnt work ill do more research ty
jeth`

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.