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 string.
$str='';
foreach($dataarray as $value)
{
$str.=$value."##";
}
it gives me string like ABC##DEF##GHI##
I have to remove last 2 chars ##
EDIT:
have shown here sample code . actull y array is 2D. so cant use implode()
If the
implodemethod isn’t appropriate, then after yourforeachloop, you can try one of these functions:http://www.php.net/manual/en/function.rtrim.php
http://php.net/manual/en/function.substr.php
If you have a 2D array, you could still use the
implodefunc like this: