[PHP] need to change $ char in string
I've tried everything I can think of to change a dallar sign in a string to something else or to split the string on the $ but I can't the the information that comes after the $. Typical string contains: 1.2$General/ms1.zip when I try: $new_string = preg_replace("/\$/", "%", $test_string); or (trying to avoid specifying the $): $new_string = preg_replace("/(\d\.\d{1,2})\D(\w.*$)/", "\1%\2", $test_string); echo "new_string is $new_string"; prints new_string is 1.2 Has anyone solved this problem? Thanx, Bev -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need to change $ char in string
Jason, Thanx for your suggestion but I tried it and it didn't work. I'm not sure if it matters, but this running on NT. Bev -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 29, 2002 12:05 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] need to change $ char in string On Saturday 29 June 2002 22:58, Beverly Steiner wrote: > I've tried everything I can think of to change a dallar sign in a string to > something else or to split the string on the $ but I can't the the > information that comes after the $. > > Typical string contains: 1.2$General/ms1.zip > > when I try: > $new_string = preg_replace("/\$/", "%", $test_string); Try: $new_string = preg_replace("/\\$/", "%", $test_string); -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Pity the meek, for they shall inherit the earth. -- Don Marquis */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Limiting number of decimal places reported
John, Try using the number_format function. Bev -Original Message- From: John Wulff [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 29, 2002 3:10 PM To: [EMAIL PROTECTED] Subject: [PHP] Limiting number of decimal places reported How do I limit the number of decimal places returned in this query? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need to change $ char in string
Uli & others, Thanx for the suggestions. This works as stated but the data already exists in this format from an old database and I'm trying to parse it into logical fields. Originally the data in the field looked something like 1$General/ms1.zip#12$Another/xqy.zip#. I deleted the ending # then used explode to separate the information on the # and now I need to separate the info before the $ from what comes after it. I've tried everyone's suggestions but they only work if I'm testing and can define the string using single quotes. How can I split on a $ or change the $ to something else if I'm getting the information from a database (MySQL), not defining it using single quotes like in your example? Bev -Original Message- From: Uli B [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 29, 2002 11:56 AM To: PHP List Subject: Re: [PHP] need to change $ char in string use single quotes: double quotes would confuse php with variable names. it thinks that $General is a variable and replace it by it's empty content. single quotes prevent php from evaluating the string: $test_string = '1.2$General/ms1.zip'; single quotes on regex too (same reason). the backslash in this case (\$) refers to perl regular expression syntax but does not take care of php ! $new_string = preg_replace('/\$/', "%", $test_string); ub At 10:58 29.06.02 -0400, Beverly Steiner wrote: >I've tried everything I can think of to change a dallar sign in a string to >something else or to split the string on the $ but I can't the the >information that comes after the $. > >Typical string contains: 1.2$General/ms1.zip > >when I try: > $new_string = preg_replace("/\$/", "%", $test_string); > >or (trying to avoid specifying the $): > $new_string = preg_replace("/(\d\.\d{1,2})\D(\w.*$)/", "\1%\2", >$test_string); > >echo "new_string is $new_string"; prints new_string is 1.2 > >Has anyone solved this problem? > >Thanx, > >Bev > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- --- Ulrich Borchers Brandenberger Straße 18, 41065 Mönchengladbach fon +49-2161-175883 icq 1282868 --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need to change $ char in string
Jason, Thank you, explode using single quotes and no backslashes works! Bev -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Monday, July 01, 2002 10:57 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] need to change $ char in string On Monday 01 July 2002 22:47, Beverly Steiner wrote: > Uli & others, > > Thanx for the suggestions. This works as stated but the data already > exists in this format from an old database and I'm trying to parse it into > logical fields. Originally the data in the field looked something like > 1$General/ms1.zip#12$Another/xqy.zip#. I deleted the ending # then used > explode to separate the information on the # and now I need to separate the > info before the $ from what comes after it. I've tried everyone's > suggestions but they only work if I'm testing and can define the string > using single quotes. > > How can I split on a $ >or change the $ to something else if I'm getting the > information from a database (MySQL), not defining it using single quotes > like in your example? I think you're confused. There is nothing in MySQL which dictates strings as single-quoted or double-quoted. I think you had best post some code. Show us how you're retrieving the data from MySQL. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Two heads are better than one. -- John Heywood */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] extracting data from text file
Here's one way assign each line: "; echo "state is $state"; echo "city is $city"; echo "comapny is $company"; echo "division is $division"; echo "url is $url"; echo "email is $email"; fclose($whattoread); ?> Bev -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, July 01, 2002 5:17 PM To: php-general Subject: [PHP] extracting data from text file Hello , I have a text file that looks like this. each entry is on a different line I need to pull the data out of it and put each line of data into its own variable US State City Company Name Section 2 www.domain.com [EMAIL PROTECTED] I have trend this but it does not work properly $fp = @fopen(file.txt,"r"); $line = explode("\n",$fp); $valueC = "$line[0]"; $valueST = "$line[1]"; @fclose($fp); -- Best regards, rdkurth mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] uploading a file
Balaji, I tried to implement the code you put in this email and I'm having some problems. I am able to browse and choose a file from my system then click upload. The php script doesn't get the value of $path. The site is running PHP 4.2.1 on Windows NT 5.0. I am using Internet Explorer 6.0.26. Any suggestions on what I need to add? Thanx, Bev -Original Message- From: Balaji Ankem [mailto:[EMAIL PROTECTED]] Sent: Monday, July 01, 2002 12:11 PM To: 'Phil Schwarzmann' Cc: [EMAIL PROTECTED] Subject: RE: [PHP] uploading a file Upload.html === FileUpload function check() { document.upload.method = "POST"; document.upload.enctype='multipart/form-data' document.upload.action="upload.php"; document.upload.submit(); return true; } File & nbsp; Upload.php Your file $path_name has been uploaded!!!" ; } else { print "A problem was encountered during your file upload."; } ?> = -Original Message- From: Phil Schwarzmann [mailto:[EMAIL PROTECTED]] Sent: Monday, July 01, 2002 9:29 PM To: [EMAIL PROTECTED] Subject: [PHP] uploading a file anyone have some code they can send me that will successfully upload a file? I've got all the HTML correct, it's just that my PHP code ain't working. Thanks! Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php