Solved

How to substitute the special href in PHP?

Posted on 2013-05-23
5
278 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
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ebay api to see some data about my customers 2 26
div to fit another div 8 20
Why a span is lower 2 18
Button and js nou working 3 6
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now