?
Solved

Limit URL length - PHP

Posted on 2013-12-10
5
Medium Priority
?
272 Views
Last Modified: 2014-10-22
Hello experts,

I need to setup the length of the URL created in the result set from my search engine. It needs to be up to 250 characters.

I retrieve the unique number of each study from id and its name from name

The name parameter is the one that should be limited because contains the study title.

  printf("<td><a href='http://mywebsite.com/%s,&radio=$radio,%s' target=\"_blank\">%s</a></td>",$row['id'], str_replace( $simbolos_reemplazar, "_", $row['name']), $row['name']);

Open in new window


Thanks in advance for the help
0
Comment
Question by:Klaus Andersen
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39708229
Try the built-in PHP function substr($thing,0,250);
0
 

Author Comment

by:Klaus Andersen
ID: 39708251
Thanks Ray, I will try. It's ok my syntax?

printf("<td><a href='http://mywebsite.com/%s,&radio=$radio,%s' target=\"_blank\">%s</a></td>",$row['id'], str_replace( $simbolos_reemplazar, "_", $row['name']), $row['name']), substr($row[name],0,250);

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39708335
I don't know.  I am pretty sure you have unbalanced parentheses that will cause a parse error, but I can't really test it since I don't have your test data set.  I usually recommend that programmers avoid compound statements (AntiPractice #9) because it may be difficult to look at your code and know whether it will work or not.  Try breaking the code up into units that are susceptible of being examined one-at-a-time and you'll probably spend less time debugging!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question