href preg replace
Ik probeer een stukje bij in een regel te plakken ik heb de volgende regel:
<area shape="circle" coords="187,211,26" href="1">
en deze moet zo worden:
<area shape="circle" coords="187,211,26" href="javascript:winopen(\'punt.php?ID=11&punt=1')">
ik probeer het met de volgende code maar dat werkt niet.
Toevoeging op 10/03/2011 08:18:35:
Oke inmiddels is het opgelost met de volgende code
<area shape="circle" coords="187,211,26" href="1">
en deze moet zo worden:
<area shape="circle" coords="187,211,26" href="javascript:winopen(\'punt.php?ID=11&punt=1')">
ik probeer het met de volgende code maar dat werkt niet.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$return = '<map name="route4" id="route4">
<area shape="circle" coords="187,211,26" href="1">
<area shape="circle" coords="353,142,26" href="2">
<area shape="circle" coords="121,303,26" href="3">
<area shape="circle" coords="221,315,26" href="4">
<area shape="circle" coords="107,351,26" href="5">
<area shape="circle" coords="284,295,26" href="6">
<area shape="circle" coords="383,331,26" href="7">
</map>';
$return = preg_replace(
"~<area.*?href=\"(.*?)\".*?><area shape=\"(.*?)\" coords=\"(.*?)\" href=\"(.*)\">/i",
"<area shape=\"\\1\" coords=\"\\2\" href=\"javascript:winopen(\'punt.php?ID=11&punt=\\3\')\">",$return);
?>
$return = '<map name="route4" id="route4">
<area shape="circle" coords="187,211,26" href="1">
<area shape="circle" coords="353,142,26" href="2">
<area shape="circle" coords="121,303,26" href="3">
<area shape="circle" coords="221,315,26" href="4">
<area shape="circle" coords="107,351,26" href="5">
<area shape="circle" coords="284,295,26" href="6">
<area shape="circle" coords="383,331,26" href="7">
</map>';
$return = preg_replace(
"~<area.*?href=\"(.*?)\".*?><area shape=\"(.*?)\" coords=\"(.*?)\" href=\"(.*)\">/i",
"<area shape=\"\\1\" coords=\"\\2\" href=\"javascript:winopen(\'punt.php?ID=11&punt=\\3\')\">",$return);
?>
Toevoeging op 10/03/2011 08:18:35:
Oke inmiddels is het opgelost met de volgende code
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$return = '<map name="route4" id="route4">
<area shape="circle" coords="187,211,26" href="1">
<area shape="circle" coords="353,142,26" href="2">
<area shape="circle" coords="121,303,26" href="3">
<area shape="circle" coords="221,315,26" href="4">
<area shape="circle" coords="107,351,26" href="5">
<area shape="circle" coords="284,295,26" href="6">
<area shape="circle" coords="383,331,26" href="7">
</map>';
$return = preg_replace(
"/href\=\"(.*?)\"/",
"href=\"javascript:winopen('punt.php?ID=11&punt=$1')\"",$return);
?>
$return = '<map name="route4" id="route4">
<area shape="circle" coords="187,211,26" href="1">
<area shape="circle" coords="353,142,26" href="2">
<area shape="circle" coords="121,303,26" href="3">
<area shape="circle" coords="221,315,26" href="4">
<area shape="circle" coords="107,351,26" href="5">
<area shape="circle" coords="284,295,26" href="6">
<area shape="circle" coords="383,331,26" href="7">
</map>';
$return = preg_replace(
"/href\=\"(.*?)\"/",
"href=\"javascript:winopen('punt.php?ID=11&punt=$1')\"",$return);
?>
Gewijzigd op 09/03/2011 16:07:37 door DirkJan Heinen
Gesponsorde koppelingen:
Er zijn nog geen reacties op dit bericht.



