You are viewing an old revision of this post, from April 13, 2017 @ 17:15:36. See below for differences between this version and the current revision.

Php – Remove the last character from string

I have a string like

a,b,c,d,e,

I would like to remove last ',' and get the remaining string back

OUTPUT: a,b,c,d,e

Here is what i did 

echo rtrim("a,b,c,d,e,", ",")

 

Hope it helps ^^

Revisions

  • April 13, 2017 @ 17:15:46 [Current Revision] by Sharing Solution
  • April 13, 2017 @ 17:15:46 by Sharing Solution
  • April 13, 2017 @ 17:15:36 by Sharing Solution

Revision Differences

April 13, 2017 @ 17:15:36Current Revision
Content
Unchanged: <p>Unchanged: <p>
Unchanged: I have a string likeUnchanged: I have a string like
Unchanged: </p>Unchanged: </p>
Unchanged: <pre>Unchanged: <pre>
Unchanged: <code>a,b,c,d,e,< /code></pre>Unchanged: <code>a,b,c,d,e,< /code></pre>
Unchanged: <p>Unchanged: <p>
Unchanged: I would like to remove last &#39;,&#39; and get the remaining string backUnchanged: I would like to remove last &#39;,&#39; and get the remaining string back
Unchanged: </p>Unchanged: </p>
Unchanged: <pre>Unchanged: <pre>
Unchanged: <code>OUTPUT: a,b,c,d,e</code></pre>Unchanged: <code>OUTPUT: a,b,c,d,e</code></pre>
Unchanged: <p>Unchanged: <p>
Unchanged: Here is what i did&nbsp;Unchanged: Here is what i did&nbsp;
Unchanged: </p>Unchanged: </p>
Unchanged: <p>Unchanged: <p>
Deleted: echo rtrim(&quot;a,b,c,d,e,&quot;, &quot;,&quot;) Added: <strong>echo rtrim(&quot;a,b,c,d,e,&quot;, &quot;,&quot;)</strong>
Unchanged: </p>Unchanged: </p>
Unchanged: <p>Unchanged: <p>
Unchanged: &nbsp;Unchanged: &nbsp;
Unchanged: </p>Unchanged: </p>
Unchanged: <p>Unchanged: <p>
Unchanged: Hope it helps ^^Unchanged: Hope it helps ^^
Unchanged: </p>Unchanged: </p>

Note: Spaces may be added to comparison text to allow better line wrapping.

No comments yet.

Leave a Reply