Re: Parsing database variables

From: Date: Fri, 30 Mar 2007 21:34:01 +0000
Subject: Re: Parsing database variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-251803@lists.php.net to get a copy of this message
Jake McHenry wrote:
thought about that, I would need to do one ereg for each variable then correct? as of right now, there are 0 variables in the first field, and 17 in the second... so it would be 17 ereg replaces... then if i add or change anything, possibly more... This will work, but was hoping for an easier way... Jake _____ From: Daniel Brown [mailto:parasane@gmail.com] Sent: Friday, March 30, 2007 5:02 PM To: Jake McHenry Subject: Re: [PHP] Parsing database variables
    Jake, could you use ereg_replace() to do that?
<? //.... while($row = mysql_fetch_array($result)) {
    $html = ereg_replace("$"."name",$name,$row['column_name'];
} 
    I split the first field of the ereg_replace() input so that it wouldn't
be read by the function as a variable. On 3/30/07, Jake McHenry <HYPERLINK "mailto:linux@nittanytravel.com"linux@nittanytravel.com> wrote: Sorry.. Typos... But that's not the point... I looked the function... Dunno how I missed it.... Thanks... Do you know if eval() has any size limitations to it? The database fields are about a page each.... Thanks, Jake I would suggest writing a function in which the parameters are passed in as references. In the function itself have set a variables using the heredoc syntax, which incorporates the variables, and then return the heredoc variable. Coming from Perl, my impulse is to use a reference for the return value, but the manual says not to, that PHP is smart enough to know how to optimize itself. Perhaps someone can tell us whether the same is true for the parameters. The manual is mum on that one.
function set_func(&$var1, &$var2 . . . &var17) { $return_var = RETURNVAR "this is $var1 and $var2. . . ."; RETURNVAR ; return $return_var; } _____________________ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/

« previous php.general (#251803) next »