[PHP] Concatenate PHP code into a string
Dear List, How can I include a dynamically generated array: e.g. for($i=0; $isizeof($cols); $i++) { $cols[$i]= mysql_field_name($fields,$i); } into a MySQL insert query of the type: $sql= INSERT cols[0],cols[1],cols[2], ..., comment INTO mytable SET cols[0]= '$cols[0]', cols[1]= '$cols[1]', cols[2]= '$cols[2]', cols[...]= '$cols[...]', comment= '$comment'; The number of $cols is different for each table. Thanks in advance for any help Alberto Brea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Concatenate PHP code into a string
Dear List, How can I include a dynamically generated array: e.g. for($i=0; $isizeof($cols); $i++) { $cols[$i]= mysql_field_name($fields,$i); } into a MySQL insert query of the type: -snip- /** {{{2 * create an INSERT or UPDATE query based on values of an associative array, * where keys are the column names to be modified. * * @param arrayvalues an associative array * @param string table the table name * @param string type the query type, currently only 'INSERT' or * 'UPDATE' * @return mixed a SQL query string on success, false otherwise (e.g., no * keys found matching valid column names) */ function array_to_query($values, $table, $type) // {{{3 { if(!is_array($values)) return false; foreach($values as $col = $val) { $values[$col] = db::quote($val); if(is_null($val)) unset($values[$col]); } switch($type) { case 'INSERT': $query = sprintf('INSERT INTO %s (%s) VALUES (%s)', $table, join(',', array_keys($values)), join(',', $values)); break; case 'UPDATE': foreach($values as $col = $val) $values[$col] = ${col} = ${val}; $query = UPDATE $table SET . join(',', $values); break; default: trigger_error(Unrecognized query type '$type' supplied to db_array_to_query(), E_USER_WARNING); return false; } return $query; } - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Concatenate
how can i concatenate two strings? i cant seem to find the function... thanks :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Concatenate
On Mon, 30 Jun 2003, Ryan Vennell wrote: how can i concatenate two strings? i cant seem to find the function... thanks :) With . Derick -- Interpreting what the GPL actually means is a job best left to those that read the future by examining animal entrails. - Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Concatenate
you can do it by assigning them to a single string or by adding the second to the firsst $youroriginalfirststring .= $thestringyouwanttoadd; please note the . Chris - Original Message - From: Derick Rethans [EMAIL PROTECTED] To: Ryan Vennell [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, June 30, 2003 8:32 AM Subject: Re: [PHP] Concatenate On Mon, 30 Jun 2003, Ryan Vennell wrote: how can i concatenate two strings? i cant seem to find the function... thanks :) With . Derick -- Interpreting what the GPL actually means is a job best left to those that read the future by examining animal entrails. - Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ - -- 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] Concatenate
how can i concatenate two strings? i cant seem to find the function... thanks :) Read this: http://www.php.net/manual/en/language.operators.string.php And then this: http://www.php.net/manual/en/language.types.string.php Regards, Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] concatenate?
On Tue, 28 Aug 2001 16:34:44 +0100, [EMAIL PROTECTED] (Seb Frost) wrote: $string0 = hello; $string1 = goodbye; $string2 = $string0 . and . $string1; result:$string2 = hello and goodbye also, $string2=$string1 and $string2; i'm not sure if there are subtleties there that make this not as good as the preceding answer. generally i go with this one since it's shorter and is, for me, more readable. does anyone know of a scenario (perhaps involving non-string data) where the concatenation does not return the same answer? tiger -- 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]
Re: [PHP] concatenate?
does anyone know of a scenario (perhaps involving non-string data) where the concatenation does not return the same answer? If you have three vars: $user = foo; $users = array(Peter,Michael); This could be a problem: echo $users hair is brown; if what you ment was: echo $string.s hair is brown; // Peters hair is brown Regards, Søren PS: In Danish (I'm Danish) you write 'Peters hair' and not 'Peter's hair' which why I made this silly example :-) -- 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]
Re: [PHP] concatenate?
?php $user=alalaba; echo ${user}s here; ? Produces : alalabas here ?php $user=array(alalaba); echo ${user}s here; ? Produces : Arrays here Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: Soeren Nielsen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 29, 2001 3:46 PM Subject: Re: [PHP] concatenate? does anyone know of a scenario (perhaps involving non-string data) where the concatenation does not return the same answer? If you have three vars: $user = foo; $users = array(Peter,Michael); This could be a problem: echo $users hair is brown; if what you ment was: echo $string.s hair is brown; // Peters hair is brown Regards, Søren PS: In Danish (I'm Danish) you write 'Peters hair' and not 'Peter's hair' which why I made this silly example :-) -- 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 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] concatenate?
Hello, I was just wondering if there was a simple function like str_con or something like that to concatenate strings? -- 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]
RE: [PHP] concatenate?
$string0 = hello; $string1 = goodbye; $string2 = $string0 . and . $string1; result:$string2 = hello and goodbye - seb -Original Message- From: Jeremy Morano [mailto:[EMAIL PROTECTED]] Sent: 28 August 2001 16:28 To: [EMAIL PROTECTED] Subject: [PHP] concatenate? Hello, I was just wondering if there was a simple function like str_con or something like that to concatenate strings? -- 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] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.274 / Virus Database: 144 - Release Date: 23/08/2001 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.274 / Virus Database: 144 - Release Date: 23/08/2001 -- 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]
RE: [PHP] concatenate vars?
no, you need to do three different comparisons : if( ... something ... ) (eregi("stuff1", $one) and eregi("stuff2", $two) and eregi("stuff3", $three)) ? : do this : do that Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: W.D. [mailto:[EMAIL PROTECTED]] Sent: Friday, February 23, 2001 5:38 AM To: Philip Olson Cc: [EMAIL PROTECTED] Subject: Re: [PHP] concatenate vars? Thanks, do you know if making multiple statements to eregi in line 3 is possible? 1. if(...something...) 2.{ 3. (eregi("stuff1", $one)("stuff2", $two)("stuff3", $three)) ? 4. do something : do something else; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- 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 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] concatenate vars?
I need to combine two variables which are set to two form field values and will be put into $from of mail(). Should it be $from = "$varOne . $varTwo" ? also a way to make if(.something) (eregi("blah", $one)("blah2", $two)("blah3", $three));will this work? _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- 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]
Re: [PHP] concatenate vars?
I need to combine two variables which are set to two form field values and will be put into $from of mail(). Should it be $from = "$varOne . $varTwo" ? Check out : Using Strings : - http://www.zend.com/zend/tut/using-strings.php PHP Manual : Strings: - http://www.php.net/manual/en/language.types.string.php The above will explain everything. The following will work : $var_a = 'the'; $var_b = 'dog'; $from = $var_a . $var_b; // thedog $from = $var_a . ' big ' . $var_b; // the big dog Regards, Philip Olson http://www.cornado.com/ -- 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] Concatenate a variable.
Hello. I receive from a post T1, T2, T3, ... Tn I want to put then in an array with a for, how can I do that? How can I use $T$i ??? Thank you Fabian Fabela [EMAIL PROTECTED] www.vacagorda.com
Re: [PHP] Concatenate a variable.
Sorry I know the answer now. Thank you Fabian Fabela From: "Fabian Fabela" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, February 15, 2001 3:30 AM Subject: [PHP] Concatenate a variable. Hello. I receive from a post T1, T2, T3, ... Tn I want to put then in an array with a for, how can I do that? How can I use $T$i ??? Thank you Fabian Fabela [EMAIL PROTECTED] www.vacagorda.com -- 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]