It might be a simple task. But I am new to PHP.
I am creating a string of values getting from database for a specific purpose.
How to remove last char from s
If the implode
method isn't appropriate, then after your foreach
loop, you can try one of these functions:
http://www.php.net/manual/en/function.rtrim.php
$str = rtrim($str,'#');
http://php.net/manual/en/function.substr.php
$str = substr($str,-2);
If you have a 2D array, you could still use the implode
func like this:
$a = array();
foreach( $foo as $bar )
foreach( $bar as $part )
$a[] = $part;
$str = implode('##',$a);