NameSilo

PHP Help

Spaceship Spaceship
Watch

hoops

Established Member
Impact
0
I have a PHP script that pulls a .txt file and displays the results for
me.

I need the scipt to limit the number of letters it shows to me to not more than 15 letters, but not 15 letters exactly.

Can someone show me a code example on how to do this please?

Thanks!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
What do you mean exactly? Why not always show 15 characters? In which cases do you want it to show less than 15?
 
0
•••
What do you mean exactly? Why not always show 15 characters? In which cases do you want it to show less than 15?

Yes less than 15 characters.
 
0
•••
So you want to pull the data from a txt file and show results for words with 1-15 letters. Correct?
 
0
•••
So you want to pull the data from a txt file and show results for words with 1-15 letters. Correct?

Yes - I have all of the code and it works find with displaying the characters, but I need from 1-15 characters only.

Here is the line that I think needs to be edited.

$length = (strlen($length) > 0) ? $length : null;
 
0
•••
PHP:
$catString = substr($length,0,15);
 
0
•••
If your using this in a loop of strings below will allow anything greater then 0 characters and less then 15 characters

Code:
$length = (strlen($length) > 0 AND strlen($length) <= 15) ? $length : null;
 
0
•••
I think you want just 1-15 letters. Then you should try the following code.
$length = (strlen($length) >= 1 AND strlen($length) <= 15) ? $length : null;
I hope after using this code, you will solve your problem.
Thank you.
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back