Re: Parsing database variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Myron Turner wrote:
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@xxxxxxxxx] Sent: Friday, March 30, 2007 5:02 PM
To: Jake McHenry
Subject: Re:  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@xxxxxxxxxxxxxxxxx"linux@xxxxxxxxxxxxxxxxx> 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/

Should be:

$return_var = RETURNVAR
this is  $var1 and $var2. . . .
RETURNVAR ;

--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux