[PHP] Re: Dynamic constant names -SOLVED
My apologies for assuming too much of the variable names. Thank you for correcting me. Your response has caused me good confusion though. If I remove the ${...} notation I get quite a different output (specifically, there's no output). Are you sure the parser ignores it? This is the code I suggested WITHOUT the ${...} that returns nothing. $test_name="ta_dah"; define("constant_name","test_name"); $constant_value=$constant_name; echo $constant_value; And I wonder too if my odd usage of ${...} notation is improper in variables. When I want to create a dynamically named variable (as opposed to my off-topic constant example), I use: ${$variable_name}="value"; or even ${"fixed_string".$variable_name}="value"; I hope I'm not going against sane practices in doing so. On Wed, 28 Mar 2001, Geoff Caplan wrote: Art, Thanks for the suggestion, but I think there is a flaw in your solution. The original issue was how to get at the value of a constant where the $constant_name is dynamically created as a variable. In your solution you have defined constant_name as a constant! So when you assign it, it does, of course, behave as a constant. I don't think the ${...} notation is doing anything - it is just being ignored by the parser so far as I can see ... AW $test_name="ta_dah"; AW define("constant_name","test_name"); AW $constant_value=${constant_name}; Geoff Caplan -- March 27, 2001: Tuesday is a scissors. Opposed blades make a finer cut. --http://artwells.com/oracula/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Get rid of da Zero's
preg_replace("/0+$/","",$number); On Thu, 25 Jan 2001, Ethan Nelson wrote: Almost there... actually this creates one problem... It turns 40.00 into 4 It needs to quit shaving zero's when it hits the decimal point. 40.00 into 40 45.50 into 45.5 40.25 into 40.25 Thanks -Original Message- From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 25, 2001 12:43 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Question about dopping zeros ereg_replace("[0\.]*$", "", $number) should do it. I'm not sure you need the slash in front of the dot or not. try it and see. In article [EMAIL PROTECTED] you write: I need to format decimals that are percise to the second place in the following format: 4.00 to 4 4.50 to 4.5 4.25 to 4.25 As you can see, I just want to drop the trailing zeros, and if necessary the decimal. Thanks ___ Ethan Nelson, Systems Administrator Net Solutions, LLC 840 Lawrence Street Eugene, OR 97401 [EMAIL PROTECTED] http://www.netsolutionsllc.com Voice +1 541 345-7087 Fax +1 541 485-5519 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- http://www.artwells.com/ That which indicates nothing introduces everything. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Fwd: Help - removal of trailing zeros from double integer field
This might help. $no_trailing_zeroes = preg_replace("/0+$/","",$trailing_zeroes); Dear friends, I am accessing MySQL database using apache and php. I have to display a double integer field without trailing zeros. The number of digits after the decimal point varies. I have tried searching the archive and did not get any previous questions. Kindly help me in this regard. Thanking you. Sincerely, Raveendra Reddy B National Law School Bangalore India E-mail: [EMAIL PROTECTED] - End forwarded message - -- http://www.artwells.com/ That which indicates nothing introduces everything. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]