Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to substitute the special href in PHP?

Posted on 2013-05-23
5
Medium Priority
?
324 Views
Last Modified: 2013-05-30
Hi Experts

I'm facing a difficulty to deal with the anchor
<tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td>

How could it be understood and changed?

In how to substitute it with something like that
  <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

since if I do that the effects are unwanted, accordingly with the Picture:

Img001
Original code

	<h4>Forms</h4>
<table cellspacing="0">
			<tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td>
            
            <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

				<td><a href="examples/?eid=grid/json-grid">JSON Grid</a></td></tr>			
			<tr><td><a href="examples/?eid=grid/xml-grid">XML Grid</a></td>
				<td><a href="examples/?eid=grid/edit-grid">Editor Grid</a></td></tr>
			<tr><td><a href="examples/?eid=grid/grouping">Array Grouping Grid</a></td>
				<td><a href="examples/?eid=grid/grouping_json-grid">JSON Grouping Grid</a></td></tr>			
		</table>			


		</table>
		<h4>Grids</h4>

Open in new window


Code planned:

		<h4>Grids</h4>
		<table cellspacing="0">
			<!--tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td-->
            
            <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

				<td><a href="examples/?eid=grid/json-grid">JSON Grid</a></td></tr>			
			<tr><td><a href="examples/?eid=grid/xml-grid">XML Grid</a></td>
				<td><a href="examples/?eid=grid/edit-grid">Editor Grid</a></td></tr>
			<tr><td><a href="examples/?eid=grid/grouping">Array Grouping Grid</a></td>
				<td><a href="examples/?eid=grid/grouping_json-grid">JSON Grouping Grid</a></td></tr>			
		</table>

Open in new window


Here the Project structure under Apache htdocs, it's the PHP-Ext libraries.

Img002
Since I'd like to use the code in a different context without this kind of anchor, what must be done?

Thanks in advance!
0
Comment
Question by:Eduardo Fuerte
[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
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 2000 total points
ID: 39191046
I don't know how did you generate the above links but no problem it's may be static or dynamic generated. Ok lets create a function for this work will be better to reuse every where you need. I assume that each of your a links are separated using examples/?eid= that's why I am exploding them in array see the function below first:

 <?php
																	function manageUrl($url){
																		$vals=explode('/?eid=',$url);
																		$j= count($vals)-1;
																		for($i=0; $i<sizeof($vals); $i++){
																			if($j>$i){
																			echo $vals[$i]."/";
																			}else{
																				echo $vals[$i].".php";
																			}
																		}
																	}
																	?>

Open in new window


Now call the function in your a link

<h4>Forms</h4>
		<table cellspacing="0">
			<tr><td><a href="<?php echo manageUrl('examples/?eid=form/anchoring');?>">Anchoring</a></td>
			<td><a href="<?php echo manageUrl('examples/?eid=form/combos');?>">Combos</a></td></tr>
			<tr><td><a href="<?php echo manageUrl('examples/?eid=form/custom');?>">Custom</a></td>
			<td><a href="<?php echo manageUrl('examples/?eid=form/dynamic');?>">Dynamic</a></td></tr>
			<tr><td><a href="<?php echo manageUrl('examples/?eid=form/form-grid');?>">Form Grid</a></td>
			<td><a href="<?php echo manageUrl('examples/?eid=form/forum-search');?>">Forum Search</a></td></tr>
			<tr><td colspan="2"><a href="<?php echo manageUrl('examples/?eid=form/xml-form');?>">Xml Form</a></td></tr>
		</table>
		<h4>Grids</h4>
		<table cellspacing="0">
			<!--tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td-->
            
            <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

				<td><a href="<?php echo manageUrl('examples/?eid=grid/json-grid');?>">JSON Grid</a></td></tr>			
			<tr><td><a href="<?php echo manageUrl('examples/?eid=grid/xml-grid');?>">XML Grid</a></td>
				<td><a href="<?php echo manageUrl('examples/?eid=grid/edit-grid');?>">Editor Grid</a></td></tr>
			<tr><td><a href="<?php echo manageUrl('examples/?eid=grid/grouping');?>">Array Grouping Grid</a></td>
				<td><a href="<?php echo manageUrl('examples/?eid=grid/grouping_json-grid');?>">JSON Grouping Grid</a></td></tr>			
		</table>

Open in new window

0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39191050
Sorry I use php code in above see the function here:
function manageUrl($url){
	$vals=explode('/?eid=',$url);
	$j= count($vals)-1;
	for($i=0; $i<sizeof($vals); $i++){
		if($j>$i){
		echo $vals[$i]."/";
		}else{
			echo $vals[$i].".php";
		}
	}
}																	}

Open in new window

0
 

Author Comment

by:Eduardo Fuerte
ID: 39191149
It's not a simple kind of get transformed one string in another...
The problem remains the same.
0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39191178
What Exactly you want to do?? As you start:

I'm facing a difficulty to deal with the anchor
<tr><td><a href="examples/?eid=grid/array-grid">Array Grid</a></td>

How could it be understood and changed?

In how to substitute it with something like that
  <tr><td><a href="examples/grid/array-grid.php">Array Grid</a></td>

since if I do that the effects are unwanted, accordingly with the Picture:
0
 

Author Comment

by:Eduardo Fuerte
ID: 39191293
I just want to call directly a .php without to get the unwanted effects instead of get the code executed.

Maybe if you could download the PHP-ext and test it by yourself it could be easier to understand.

By the way, thank you for your efforts!
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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to count occurrences of each item in an array.

705 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