i need help. i was developed a page in smarty , i got a result set from a query and i need to change the result set to string and stored in text area
my query is given below
select val from test
my result set is print in var_dump in controller
{ [0]=> array(1) { ["val"]=> string(1) "c" } [1]=> array(1) { ["val"]=> string(3) "c++" } [2]=> array(1) { ["val"]=> string(4) "java" } [3]=> array(1) { ["val"]=> string(3) "PHP" } }
i need to change in to sting like c,c++,java,PHP
the changing function is preformed only controller
ple help me.. and thk adv
Use foreach for that. See more information here – http://php.net/manual/en/control-structures.foreach.php .
Example –
Another solution would be to use implode.
See more information here – http://php.net/manual/en/function.implode.php and again a small example –
EDIT:
For writing in file you must use file functions.
Check this link – http://php.net/manual/en/function.file-put-contents.php
example –
Suggestion:
When you are writing SQL queries, I would suggest that you already now start learning to write them correctly, so they are easier to read.
For example, your query –
Could be changed to –
which is alot easier to read and understand.