Removing last chars from the string
We only know how many chars to be removed from string.
Above code will remove last 3 chars from the string $q.
Some time we develop Query where we don't know how many items are there in the list. For example let us see this query.
To our original query we may add variable part like this
To generate this query we may have to loop through a for loop or any other loop and generate the variable part of the query string with one extra coma ( , ) at the end .
To remove the extra one char at the end we will use like this.
This is in use for our search query generation string tutorial
We used These two string functions
strlen to know the length of the string
substr to remove part of the string
Subscribe to our YouTube Channel here
This article is written by plus2net.com team. https://www.plus2net.com