Solved

Limit URL length - PHP

Posted on 2013-12-10
5
266 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:_PJ_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 110

Accepted Solution

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

Author Comment

by:_PJ_
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 110

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 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