Re: Re: set array

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

 



implode() eg.

<?php

$names=array("Apple","Microsoft","Google","Facebook");

$longString=implode(",", $names);

echo "<br />".$longString; //$longString=Apple,Microsoft,Google,Facebook

?>


regards

Sachin Raut


On Tue, Nov 26, 2013 at 5:11 PM, John Taylor-Johnston <
jt.johnston@xxxxxxxxxxxxxx> wrote:

>
>  I just dont know how to express $_POST[DPRtype] to be able to build the
>>> $SQL to express the separate possibilities.
>>>
>>> $sql = "UPDATE `taylorjo`.`CRTP_CGA`
>>> SET
>>> `DPRtype` = '$_POST[DPRtype]'
>>> ";
>>> PHP created rtrim, but did not make something like this? Ouf, I feel
>>> like I just smashed a fly with a nuke.
>>>
>>> function express_value_select($tofilter) {
>>> $start = 0;
>>> $ToFilterSQL ="";
>>>   foreach($tofilter as $row){
>>>   $ToFilterSQL .= $row. ",";
>>>   $start++;
>>>   }
>>> if ($start > 0)
>>> $ToFilterSQL = rtrim($ToFilterSQL, ",");
>>>
>>> #echo $ToFilterSQL;
>>> return $ToFilterSQL;
>>> }
>>>
>> as David Robley wrote, implode does it. It creates a string from an array
>> using one parameter as a „glue“ character
>>
>> in any case, you would not need $start in your function. better use
>> is_array before using your function.
>>
>> for information on implode see http://us1.php.net/function.implode
>>
>> function express_value_select($tofilter) {
>>   $ToFilterSQL=implode(“,“,$tofilter);
>>   return $ToFilterSQL;
>> }
>>
>> Chris
>>
> Thanks. I have received no other posts. I will look this over.
> :) John
>
>
> --
> 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