I am building a simple price calculator for a client's client... I had found a way to figure everything else out and get it all working, except for one part. Let me explain the idea of the project first: The user is suppose to enter a password, and depending on the password that is entered, read a certain text file with prices. I used the file() command, that brings in every line as a new part of the array, I then used array_unshift to make the first line be 1 instead of zero. There is an admin area, where they can change the prices in the text file... but I would really like line numbers. I want the actual file to look like this: 1)1234 2)2345 BUT when its called to be echoed into the table, have it strip out the "number)" part... I tried to do a loop that striped out the first part using str_replace, but that only worked for 1-10... I have to up to 98. Can anyone help me find a way to do this? This is my first time writing in PHP (or anything) and I hate asking for help, but I have been looking everywhere for a solution, and I can't get one to work! Any help would be appreciated.
There are several different ways to do this.. I would use ereg if it were me.. But since this is a newb lesson: assume $strParen is "1)1234" or "98)123123" or anything)numbers $newStr = substr($strParen, 1+strpos($strParen, ")")); Code (markup): -Jason
I don't think that works... this is an array. $thefile is what its called, and goes like this: 1 => 1234 2 => 2345 ECT. When I print_r the array... it comes back with the rray... Any more help... sorry for being so dumb...
I meant, after I did what you said, that's what it printed... It would even work to trim the first 4 characters of, if I set them all to 001)... but again, how to I get it to work in an array?
I need to see the print_r output to tell you for sure.. But if you had an array that was $i[1] = "1)1238"; $i[2] = "2)120837"; $i[3] = "3)0909"; ... $i[9981] = "9981)123897" PHP: and you wanted to print out: 1238 120837 0909 ... 123897 I would use: foreach ($i as $strParen) { $newStr = substr($strParen, 1+strpos($strParen, ")")); print("$newStr<br>"); } PHP: -Jason