Re: [PHP] variable type - conversion/checking

2013-03-18 Thread Samuel Lopes Grigolato
Sorry if I'm missing something, there's a lot of replies after my first post on this thread. Is there something wrong with the "floor()" approach? I liked the regex solution but isn't it more expensive and more verbose than just doing a well commented "is_numeric" plus "floor/ceil" math? Just try

Re: [PHP] variable type - conversion/checking

2013-03-17 Thread Matijn Woudt
On Sun, Mar 17, 2013 at 10:20 PM, Maciek Sokolewicz < maciek.sokolew...@gmail.com> wrote: > On 16-3-2013 19:20, Matijn Woudt wrote: > >> On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz < >> maciek.sokolew...@gmail.com> wrote: >> >> Hi, >>> I have tried to find a way to check if a cha

Re: [PHP] variable type - conversion/checking

2013-03-17 Thread Maciek Sokolewicz
On 16-3-2013 19:20, Matijn Woudt wrote: On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz < maciek.sokolew...@gmail.com> wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg All respon

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Andrew Ballard
On Sat, Mar 16, 2013 at 12:21 PM, Ashley Sheridan wrote: > > On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote: > > On Mar 16, 2013 6:14 AM, "Ashley Sheridan" wrote: > > > > On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: > >> > >> > Guess regex are the only useful solution here. W

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Matijn Woudt
On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz < maciek.sokolew...@gmail.com> wrote: > Hi, >> >> I have tried to find a way to check if a character string is possible to >> test whether it is convertible to an intger ! >> >> any suggestion ? >> >> BR georg >> > > All responses in this thread h

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Maciek Sokolewicz
Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg All responses in this thread have been very nice; but you could also try a much simpler 2-step check: 1. is_numeric 2. if true > check if the

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Ashley Sheridan
On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote: > On Mar 16, 2013 6:14 AM, "Ashley Sheridan" wrote: > > > > On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: > >> > >> > Guess regex are the only useful solution here. When you consider to use > >> > built-in functions, just remembe

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Andrew Ballard
On Mar 16, 2013 6:14 AM, "Ashley Sheridan" wrote: > > On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: >> >> > Guess regex are the only useful solution here. When you consider to use >> > built-in functions, just remember, that for example '0xAF' is an integer >> > too, but '42.00' isn't.

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Ashley Sheridan
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: > > Guess regex are the only useful solution here. When you consider to use > > built-in functions, just remember, that for example '0xAF' is an integer > > too, but '42.00' isn't. > > Shoot...I hadn't considered how PHP might handle hex or

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread tamouse mailing lists
On Fri, Mar 15, 2013 at 8:34 PM, Ashley Sheridan wrote: >>> > On Thu, Mar 14, 2013 at 7:02 PM, >>georg >>> >>> I have tried to find a way to check if a character string is >>> >>> possible to >>> >>> test whether it is convertible to an intger ! > The op wasn't about casting a str

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Matijn Woudt
On Sat, Mar 16, 2013 at 2:54 AM, Sebastian Krebs wrote: > 2013/3/16 Andrew Ballard > > > I suppose one could try something like this: > > > > if (is_string($val) && $val === (string)(int)$val) > > > > If $val is an integer masquerading as a string, it should be identical to > > the original

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Andrew Ballard
> Guess regex are the only useful solution here. When you consider to use > built-in functions, just remember, that for example '0xAF' is an integer > too, but '42.00' isn't. Shoot...I hadn't considered how PHP might handle hex or octal strings when casting to int. (Again, not in front of a comput

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Andrew Ballard
On Mar 15, 2013 9:54 PM, "Sebastian Krebs" wrote: > > 2013/3/16 Andrew Ballard >> >> I suppose one could try something like this: >> >> if (is_string($val) && $val === (string)(int)$val) >> >> If $val is an integer masquerading as a string, it should be identical to >> the original string wh

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Sebastian Krebs
2013/3/16 Andrew Ballard > I suppose one could try something like this: > > if (is_string($val) && $val === (string)(int)$val) > > If $val is an integer masquerading as a string, it should be identical to > the original string when cast back to a string, shouldn't it? (I can't try > it right

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Sebastian Krebs
2013/3/16 Ashley Sheridan > > > tamouse mailing lists wrote: > > >On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan > >wrote: > > > >> ** > >> On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: > >> > >> On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford > >wrote: > >> > On 15/03/13 06:21,

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Andrew Ballard
I suppose one could try something like this: if (is_string($val) && $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try it right now.) Andrew

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Ashley Sheridan
tamouse mailing lists wrote: >On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan >wrote: > >> ** >> On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: >> >> On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford >wrote: >> > On 15/03/13 06:21, Jim Lucas wrote: >> >> >> >> On 3/14/2013 4:05 PM,

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread tamouse mailing lists
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan wrote: > ** > On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: > > On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford wrote: > > On 15/03/13 06:21, Jim Lucas wrote: > >> > >> On 3/14/2013 4:05 PM, Matijn Woudt wrote: > >>> > >>> On Thu, Mar

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Jim Lucas
On 03/15/2013 02:33 PM, richard gray wrote: On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid numb

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread richard gray
On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like th

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Ashley Sheridan
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: > On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford wrote: > > On 15/03/13 06:21, Jim Lucas wrote: > >> > >> On 3/14/2013 4:05 PM, Matijn Woudt wrote: > >>> > >>> On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas wrote: > >>> > On 03/14/20

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Peter Ford
On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like "if (is_numeric($var)&& $var == floor($var))" will do the trick. I don't know if there's a b

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Jim Lucas
On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like "if (is_numeric($var)&& $var == floor($var))" will do the trick. I don't know if there's a better (more elegant) way. On Thu,

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Matijn Woudt
On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas wrote: > On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: > >> Something like "if (is_numeric($var)&& $var == floor($var))" will do the >> >> trick. I don't know if there's a better (more elegant) way. >> >> >> On Thu, Mar 14, 2013 at 3:09 PM, Mat

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Jim Lucas
On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like "if (is_numeric($var)&& $var == floor($var))" will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 7:02 PM, georg wrote: Hi

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Samuel Lopes Grigolato
Something like "if (is_numeric($var) && $var == floor($var))" will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudt wrote: > On Thu, Mar 14, 2013 at 7:02 PM, georg wrote: > > > Hi, > > > > I have tried to find a way to check if a

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Matijn Woudt
On Thu, Mar 14, 2013 at 7:02 PM, georg wrote: > Hi, > > I have tried to find a way to check if a character string is possible to > test whether it is convertible to an intger ! > > any suggestion ? > > BR georg You could use is_numeric for that, though it also accepts floats. - Matijn

[PHP] variable type - conversion/checking

2013-03-14 Thread georg
Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg

RE: [PHP] variable placeholders in a text file

2013-01-07 Thread Nelson Green
On Sat, 5 Jan 2013 04:20:09 -0600, Kevin Kinsey wrote: > Nelson (et al), > > I've enjoyed reading this thread and apologize for dredging it up. > It's interesting to see your progression of thought and the templating > discussion is indeed a worthy one. > > However, I wanted to answer this object

Re: [PHP] variable placeholders in a text file

2013-01-04 Thread Kevin Kinsey
On Mon, Dec 31, 2012 at 02:29:38PM -0600, Nelson Green wrote: > > On Mon, 31 Dec 2012 19:59:02, Ashley Sheridan wrote: > ___ > > > > On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: > Nelson (et al), I've enjoyed reading this thread and apologize for dredg

RE: [PHP] variable placeholders in a text file

2013-01-01 Thread Nelson Green
> While using the *_once works in many cases, if you're doing a mass > mailing kind of thing, you want to use the standard include/require so > you can re-include it as your variables change: > > foreach ($customers as $customer) { > $fullname = $customer['fullname']; > $address = $customer['addre

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread tamouse mailing lists
On Mon, Dec 31, 2012 at 5:47 PM, Stephen wrote: > The common stuff for every page is defined in the file "include.php". I > define the variable $markup in that file. > > Here is the definition for $markup > > $markup=<< HEREDOC; > > By using require_once instead of fopen and fread, I have simpler

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Stephen
On 12-12-31 03:37 PM, Nelson Green wrote: On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr."; $user_name = 'John Doe'; $message = "Hello $title $user_name " Just define the value for the variables before defining the value for the message. Note that $

RE: [PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
On 2012-12-31, at 4:58 PM, tamouse mailing lists wrote: > I use the include("template") method for this alla time, it works > great. Most especially for HTML emails coming from a web site to a > group of users, just slick as anything. include does basically just > what your print_greeting functi

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Bastien
Bastien Koert On 2012-12-31, at 4:58 PM, tamouse mailing lists wrote: > On Mon, Dec 31, 2012 at 2:37 PM, Nelson Green > wrote: >> >> On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: >>> >>> Yes! >>> >>> Easy standard stuff. >>> >>> $title = 'Mr."; >>> $user_name = 'John Doe'; >>> >>> $mes

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread tamouse mailing lists
On Mon, Dec 31, 2012 at 2:37 PM, Nelson Green wrote: > > On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: >> >> Yes! >> >> Easy standard stuff. >> >> $title = 'Mr."; >> $user_name = 'John Doe'; >> >> $message = "Hello $title $user_name " >> >> Just define the value for the variables before defini

RE: [PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: > > Yes! > > Easy standard stuff. > > $title = 'Mr."; > $user_name = 'John Doe'; > > $message = "Hello $title $user_name " > > Just define the value for the variables before defining the value for > the message. > > Note that $message has to use do

RE: [PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
On Mon, 31 Dec 2012 19:59:02, Ashley Sheridan wrote: ___ > > On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote:   > My question is, is there another way to do something similar, such as > embedding a variable name directly into the text file? In other words, >

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Stuart Dallas
Please excuse the top post, but this may be helpful: http://stut.net/2008/10/28/snippet-simple-templates-with-php/ -Stuart -- Sent from my leaf blower On 31 Dec 2012, at 19:59, Ashley Sheridan wrote: > On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: > >> Hello, >> >> I have created

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Ashley Sheridan
On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: > Hello, > > I have created a simple function that prints a personalized greeting by > reading > the greeting contents from a file. I pass the user's name to the function, > and the function reads the file contents into a string variable. I

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Stephen
Yes! Easy standard stuff. $title = 'Mr."; $user_name = 'John Doe'; $message = "Hello $title $user_name " Just define the value for the variables before defining the value for the message. Note that $message has to use double quotes for the expansion. Also consider using HEREDOC instead

[PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
Hello, I have created a simple function that prints a personalized greeting by reading the greeting contents from a file. I pass the user's name to the function, and the function reads the file contents into a string variable. I am then using str_replace to replace the word USER in the string wit

Re: [PHP] Variable representation

2012-06-21 Thread As'ad Djamalilleil
or you can do this echo $row["Bible_knowledge_phrase_solver_game_question_topics_$i"];

RE: [PHP] Variable representation

2012-06-21 Thread admin
-Original Message- From: Ron Piggott [mailto:ron.pigg...@actsministries.org] Sent: Thursday, June 21, 2012 3:47 AM To: php-general@lists.php.net Subject: [PHP] Variable representation I am trying to represent the variable: $row['Bible_knowledge_phrase_solver_game_question_top

[PHP] Variable representation

2012-06-21 Thread Ron Piggott
I am trying to represent the variable: $row['Bible_knowledge_phrase_solver_game_question_topics_1'] Where the # 1 is replaced by a variable --- $i The following code executes without an error, but “Hello world” doesn’t show on the screen. What needs to change? Ron Ron Piggott www.TheVe

Re: [PHP] Variable Question

2012-04-19 Thread Shawn McKenzie
On 04/19/2012 09:55 AM, Christoph Boget wrote: >> I am trying to use this while look to assign them to variables: >> $word_1 >> $word_2 >> $word_3 >> ... >> $word_25 > > This should work for you: > > http://us3.php.net/manual/en/function.extract.php > > thnx, > Christoph Yes and you can use arr

Re: [PHP] Variable Question

2012-04-19 Thread Christoph Boget
> I am trying to use this while look to assign them to variables: > $word_1 > $word_2 > $word_3 > ... > $word_25 This should work for you: http://us3.php.net/manual/en/function.extract.php thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.n

Re: [PHP] Variable Question

2012-04-19 Thread Stuart Dallas
On 19 Apr 2012, at 15:46, Ron Piggott wrote: > I am trying to assign variables from an array into variables. This is > following a database query. Right now they are in an array: > > $row[‘word_1’] > $row[‘word_2’] > $row[‘word_3’] > ... > $row[‘word_25’] Why those indices? Why isn't it just

[PHP] Variable Question

2012-04-19 Thread Ron Piggott
I am trying to assign variables from an array into variables. This is following a database query. Right now they are in an array: $row[‘word_1’] $row[‘word_2’] $row[‘word_3’] ... $row[‘word_25’] I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_

Re: [PHP] Variable representation

2012-04-02 Thread tamouse mailing lists
On Mon, Apr 2, 2012 at 4:34 AM, Maciek Sokolewicz wrote: > Usually if you think you need to use eval: think again. In this case, it > again holds true. > > Instead of doing what you do, you can also reference the variable as: > echo ${'image_'.$i}; > or > echo $GLOBALS['image_'.$i]; > > Both are p

Re: [PHP] Variable representation

2012-04-02 Thread Maciek Sokolewicz
On 02-04-2012 07:15, tamouse mailing lists wrote: As for doing what you originally asked, that requires doing an eval() on the statement utilizing string interpolation, like so: eval('echo "image $i is $image_' . $i . '".PHP_EOL;'); but I think that's a bit harder to read and understand what

Re: [PHP] Variable representation

2012-04-01 Thread tamouse mailing lists
On Mon, Apr 2, 2012 at 12:20 AM, tamouse mailing lists wrote: > Ugh, gmail mangled the code there. Here's a pastebin of the response > which is better formatted: http://pastie.org/3712761 Sweet. I spent so long on my reply, two others snuck in before me. :) -- PHP General Mailing List (http://w

Re: [PHP] Variable representation

2012-04-01 Thread tamouse mailing lists
Ugh, gmail mangled the code there. Here's a pastebin of the response which is better formatted: http://pastie.org/3712761 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Variable representation

2012-04-01 Thread tamouse mailing lists
On Sun, Apr 1, 2012 at 10:52 PM, Ron Piggott wrote: > Hi Everyone: > > I am assigning the value of 4 images to variables following a database query: > > $image_1 = stripslashes( $row['image_1'] ); > $image_2 = stripslashes( $row['image_2'] ); > $image_3 = stripslashes( $row['image_3'] ); > $image_

Re: [PHP] Variable representation

2012-04-01 Thread Mihamina Rakotomandimby
On 04/02/2012 07:46 AM, Adam Randall wrote: $images[] = stripslashes( $row['image_1'] ); $images[] = stripslashes( $row['image_2'] ); $images[] = stripslashes( $row['image_3'] ); $images[] = stripslashes( $row['image_4'] ); $images[1] = stripslashes( $row['image_1'] ); $images[2] = strips

Re: [PHP] Variable representation

2012-04-01 Thread Mihamina Rakotomandimby
On 04/02/2012 06:52 AM, Ron Piggott wrote: $image_1 = stripslashes( $row['image_1'] ); $image_2 = stripslashes( $row['image_2'] ); $image_3 = stripslashes( $row['image_3'] ); $image_4 = stripslashes( $row['image_4'] ); [...] (Not all 4 variables have an image.) How is it meant in the database?

Re: [PHP] Variable representation

2012-04-01 Thread Adam Randall
It would better to just use an array, and then iterate through that. $images[] = stripslashes( $row['image_1'] ); $images[] = stripslashes( $row['image_2'] ); $images[] = stripslashes( $row['image_3'] ); $images[] = stripslashes( $row['image_4'] ); foreach( $images as $k => $v ) { $k++; /

[PHP] Variable representation

2012-04-01 Thread Ron Piggott
Hi Everyone: I am assigning the value of 4 images to variables following a database query: $image_1 = stripslashes( $row['image_1'] ); $image_2 = stripslashes( $row['image_2'] ); $image_3 = stripslashes( $row['image_3'] ); $image_4 = stripslashes( $row['image_4'] ); What I need help with is how

Re: Re: [PHP] Variable number of arguments problem

2012-02-12 Thread Tim Streater
On 12 Feb 2012 at 19:01, Stuart Dallas wrote: > Optional arguments must be given a default value... > > function my_func(&$arg1, $arg2, $arg3, $arg4 = null, $arg5 = null, &$arg6 = > null) > > Note that passing a default value by reference was not supported prior to > PHP5. > > All the relevant d

Re: [PHP] Variable number of arguments problem

2012-02-12 Thread Stuart Dallas
On 12 Feb 2012, at 18:51, Tim Streater wrote: > I have a function defined thus: > > function my_func (&$arg1, $arg2, $arg3, $arg4, $arg5, &$arg6) > { > > // code here > > } > > I call this with variously the first three arguments only, or all six, taking > care that if I call it w

[PHP] Variable number of arguments problem

2012-02-12 Thread Tim Streater
I have a function defined thus: function my_func (&$arg1, $arg2, $arg3, $arg4, $arg5, &$arg6) { // code here } I call this with variously the first three arguments only, or all six, taking care that if I call it with fewer arguments then I don't try to acces $arg4, $arg5, or $a

Re: [PHP] Variable Troubleshooting Code

2012-01-10 Thread Donovan Brooke
Jim Lucas wrote: [snip] if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) { print "$key = $value"; } [snip] I would change the above the the following: if ( empty($pmatch) || ( strpos($key, $pmatch) === 0 ) ) { print "$key = $value"; } it would be slightly faster love th

Re: [PHP] Variable Troubleshooting Code

2012-01-10 Thread Jim Lucas
On 01/09/2012 07:16 PM, Donovan Brooke wrote: Just to share, a Mr. Harkness forwarded me a consolidated version of my code.. basically substituting the innards for: if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) { print "$key = $value"; } Cheers, Donovan I would change

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Donovan Brooke
Just to share, a Mr. Harkness forwarded me a consolidated version of my code.. basically substituting the innards for: if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) { print "$key = $value"; } Cheers, Donovan -- D Brooke -- PHP General Mailing List (http://www.php.ne

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Paul M Foster
On Mon, Jan 09, 2012 at 10:42:59AM -0500, Marc Guay wrote: > > some pretty natives php functions exists to do the job : > > But how many times in my life will I have write echo ""; ??? > Does anyone have a handy solution? (Make this the default behavior? > Add a "even more human-readable" flag to

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Ashley Sheridan
Ashley Sheridan wrote: > > >Marc Guay wrote: > >>> some pretty natives php functions exists to do the job : >> >>But how many times in my life will I have write echo ""; ??? >>Does anyone have a handy solution? (Make this the default behavior? >>Add a "even more human-readable" flag to the fun

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Ashley Sheridan
Marc Guay wrote: >> some pretty natives php functions exists to do the job : > >But how many times in my life will I have write echo ""; ??? >Does anyone have a handy solution? (Make this the default behavior? >Add a "even more human-readable" flag to the function? Create a >simple macro in Ap

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Marc Guay
> some pretty natives php functions exists to do the job : But how many times in my life will I have write echo ""; ??? Does anyone have a handy solution? (Make this the default behavior? Add a "even more human-readable" flag to the function? Create a simple macro in Aptana 3?) Argz, Marc -- P

Re: [PHP] Variable Troubleshooting Code

2012-01-07 Thread David Courtin
Hi, some pretty natives php functions exists to do the job : var_export — Outputs or returns a parsable string representation of a variable debug_zval_dump — Dumps a string representation of an internal zend value to output var_dump — Dumps information about a variable print_r — Prints human-read

[PHP] Variable Troubleshooting Code

2012-01-07 Thread Donovan Brooke
Hello!, I work in another language mostly and often develop while displaying variables (post,get,and defined) and their values at the bottom of the page or in specific places. So, I thought I'd forward my PHP version as an effort of good Karma to the list perhaps! ;-) Below is 2 simple functi

Re: [PHP] Variable variable using constant

2011-10-12 Thread Marc Guay
>   $var = constant('DESKTOP_URL_' . $_SESSION['lang']); Very nice, thank you. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Variable variable using constant

2011-10-12 Thread Robert Williams
On 10/12/11 11:51, "Marc Guay" wrote: >Let's say that I have 2 constants > >DEFINE('DESKTOP_URL_en', "http://www.website.com/index.php?page=home";); >DEFINE('DESKTOP_URL_fr', >"http://www.website.com/index.php?page=accueil";); > >and I would like to populate the value of an href with them depend

[PHP] Variable variable using constant

2011-10-12 Thread Marc Guay
Hi folks, Let's say that I have 2 constants DEFINE('DESKTOP_URL_en', "http://www.website.com/index.php?page=home";); DEFINE('DESKTOP_URL_fr', "http://www.website.com/index.php?page=accueil";); and I would like to populate the value of an href with them depending on the us

RE: [PHP] Variable question

2011-10-03 Thread Ford, Mike
> -Original Message- > From: Ron Piggott [mailto:ron@actsministries.org] > Sent: 01 October 2011 18:59 > To: php-general@lists.php.net > Subject: [PHP] Variable question > > > If $correct_answer has a value of 3 what is the correct syntax > needed to use e

Re: [PHP] Variable question

2011-10-01 Thread Geoff Shang
On Sat, 1 Oct 2011, Mike Mackintosh wrote: Best bet would to toss this into either an object or array for simplification, otherwise that type of syntax would need the use of eval. example: eval('echo $trivia_answer_'.$correct_answer.';'); You could do: $var = "trivia_answer_.$correct_ans

Re: [PHP] Variable question

2011-10-01 Thread Tim Streater
On 01 Oct 2011 at 18:59, Ron Piggott wrote: > If $correct_answer has a value of 3 what is the correct syntax needed to use > echo to display the value of $trivia_answer_3? > > I know this is incorrect, but along the lines of what I am wanting to do: > > echo $trivia_answer_$correct_answer; > > $

Re: [PHP] Variable question

2011-10-01 Thread Robert Cummings
On 11-10-01 02:03 PM, Mike Mackintosh wrote: On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do:

Re: [PHP] Variable question

2011-10-01 Thread David Harkness
On Sat, Oct 1, 2011 at 10:59 AM, Ron Piggott wrote: > If $correct_answer has a value of 3 what is the correct syntax needed to > use echo to display the value of $trivia_answer_3? You can use variable variables [1] to access the variable by building its name in a string: $name = 'trivia_ans

Re: [PHP] Variable question

2011-10-01 Thread Mike Mackintosh
On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote: > > If $correct_answer has a value of 3 what is the correct syntax needed to use > echo to display the value of $trivia_answer_3? > > I know this is incorrect, but along the lines of what I am wanting to do: > > echo $trivia_answer_$correct_answe

[PHP] Variable question

2011-10-01 Thread Ron Piggott
If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do: echo $trivia_answer_$correct_answer; $trivia_answer_1 = “1,000”; $trivia_answer_2 = “1,250”; $tr

Re: [PHP] Variable scope

2011-07-14 Thread Tamara Temple
On Jul 14, 2011, at 3:54 PM, Karl DeSaulniers wrote: Can anyone explain this to me. function sendEmail($uname,$subjField,$firstname,$lastname,$email, $reply,$e_cc,$e_bcc,$comments,$ip,$Date,$time){ $uname = trim($uname); $subjField = trim($subjField); $firstname = trim($firstname);

[PHP] Variable scope

2011-07-14 Thread Karl DeSaulniers
Can anyone explain this to me. function sendEmail($uname,$subjField,$firstname,$lastname,$email, $reply,$e_cc,$e_bcc,$comments,$ip,$Date,$time){ $uname = trim($uname); $subjField = trim($subjField); $firstname = trim($firstname); $lastname = trim($lastname); $email = trim($

Re: [PHP] Variable (Class instantiation) collision

2010-10-06 Thread Brian Smither
Gentlemen, Thank you. The "Thing1 Thing2" approach worked. >If you have total control over application A which contains the bridge >code, the easiest is to change it to use a different global variable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.n

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread David Harkness
If you have total control over application A which contains the bridge code, the easiest is to change it to use a different global variable, $dbA. This must not be doable or you wouldn't have asked. If you have control over the bridge code, and it alone calls A and B, then you could swap the $db v

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Short of refactoring ApplicationB, can you set it up as a SOAP/REST service that AppA calls? On Tue, Oct 5, 2010 at 5:02 PM, Brian Smither wrote: > > >Just to clarify, both packages are instantiating and calling their > >respective classes from the $db var, which is in the global scope. > >Is t

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither
>Just to clarify, both packages are instantiating and calling their >respective classes from the $db var, which is in the global scope. >Is this correct? I would say yes to the way you are asking. Take the following two applications. The four respective statements are in each their respective sc

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Just to clarify, both packages are instantiating and calling their respective database classes from the $db var, which is in the global scope. Is this correct? This is why I hate the global scope, I hate it, I hate it! On Tue, Oct 5, 2010 at 3:47 PM, Brian Smither wrote: > I am running into a v

[PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither
I am running into a variable collision. The project I'm developing is NOT guaranteed to be operating on PHP5. Any solution I find should (hopefully) be able to run on PHP4 (yes, I know PHP4 is deprecated). I am building a bridge between two third-party applications. Both instantiate their respe

Re: [PHP] Variable in variable.

2010-08-26 Thread Jo�o C�ndido de Souza Neto
Really cool... Thanks and fogive me by my mistake. hehe -- João Cândido de Souza Neto "Robert Cummings" escreveu na mensagem news:4c76743a.2060...@interjinn.com... > On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote: >> I know that in PHP I can use this: >> >> $var1 = "text"; >> $var

Re: [PHP] Variable in variable.

2010-08-26 Thread Robert Cummings
On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote: I know that in PHP I can use this: $var1 = "text"; $var2 = '$var1'; 4cho $$var2; So it gives me "text". It would if you didn't have typos and the wrong quotes in the above :) My question is, is there a way of doing it with constant l

Re: [PHP] Variable variables into an array.

2010-08-11 Thread Richard Quadling
On 11 August 2010 13:58, Bob McConnell wrote: > From: Richard Quadling > >> Quick set of eyes needed to see what I've done wrong... >> >> The following is a reduced example ... >> >> > $Set = array(); >> $Entry = 'Set[1]'; >            ^^ > Shouldn't that be $Set[1]? > >> $Value = 'Assigned';

RE: [PHP] Variable variables into an array.

2010-08-11 Thread Bob McConnell
From: Richard Quadling > Quick set of eyes needed to see what I've done wrong... > > The following is a reduced example ... > > $Set = array(); > $Entry = 'Set[1]'; ^^ Shouldn't that be $Set[1]? > $Value = 'Assigned'; > $$Entry = $Value; > print_r($Set); > ?> Bob McConnell --

Re: [PHP] Variable variables into an array.

2010-08-11 Thread Richard Quadling
On 10 August 2010 18:08, Andrew Ballard wrote: > On Tue, Aug 10, 2010 at 12:23 PM, Richard Quadling > wrote: >> On 10 August 2010 16:49, Jim Lucas wrote: >>> Richard Quadling wrote: Hi. Quick set of eyes needed to see what I've done wrong... The following is a redu

Re: [PHP] Variable variables into an array.

2010-08-10 Thread Andrew Ballard
On Tue, Aug 10, 2010 at 12:23 PM, Richard Quadling wrote: > On 10 August 2010 16:49, Jim Lucas wrote: >> Richard Quadling wrote: >>> >>> Hi. >>> >>> Quick set of eyes needed to see what I've done wrong... >>> >>> The following is a reduced example ... >>> >>> >> $Set = array(); >>> $Entry = 'Set[

Re: [PHP] Variable variables into an array.

2010-08-10 Thread Richard Quadling
On 10 August 2010 16:49, Jim Lucas wrote: > Richard Quadling wrote: >> >> Hi. >> >> Quick set of eyes needed to see what I've done wrong... >> >> The following is a reduced example ... >> >> > $Set = array(); >> $Entry = 'Set[1]'; >> $Value = 'Assigned'; >> $$Entry = $Value; >> print_r($Set); >> ?

Re: [PHP] Variable variables into an array.

2010-08-10 Thread Jim Lucas
Richard Quadling wrote: Hi. Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... The output is an empty array. Examining $GLOBALS, I end up with an entries ... [Set] => Array ( ) [Entry] => Set[1] [Value] => Assigned

[PHP] Variable variables into an array.

2010-08-10 Thread Richard Quadling
Hi. Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... The output is an empty array. Examining $GLOBALS, I end up with an entries ... [Set] => Array ( ) [Entry] => Set[1] [Value] => Assigned [Set[1]] => Assigned A

Re: [PHP] Variable name as a variable?

2009-10-05 Thread Dotan Cohen
Thanks, all! I will experiment with the three different solutions presented and see what best fits this application. As to the security aspect, yes, I am aware that this is a simplification and that the values must be sanitized. Have a great week. -- Dotan Cohen http://what-is-what.com http://g

Re: [PHP] Variable name as a variable?

2009-10-05 Thread Lars Torben Wilson
On Mon, 5 Oct 2009 16:56:48 +0200 Dotan Cohen wrote: > I need to store a variable name as a variable. Note quite a C-style > pointer, but a way to access one variable who's name is stored in > another variable. > > As part of a spam-control measure, a certain public-facing form will > have dummy

Re: [PHP] Variable name as a variable?

2009-10-05 Thread Tommy Pham
- Original Message > From: Dotan Cohen > To: php-general. > Sent: Mon, October 5, 2009 7:56:48 AM > Subject: [PHP] Variable name as a variable? > > I need to store a variable name as a variable. Note quite a C-style > pointer, but a way to access one variable wh

  1   2   3   4   5   6   7   8   9   >