Nieuw lid |
|
Uhm? Regular Expression is niet echt mijn beste kant (lees: ik begrijp ze niet ).
<?
preg_match('/{(.*)}/', 'testtest {MENU_1} lorum ipsum {MENU_2}', $matches);
print_r($matches);
Output: Array ( [0] => {MENU_1} lorum ipsum {MENU_2} [1] => MENU_1} lorum ipsum {MENU_2 )
?>
<? preg_match('/{(.*)}/', 'testtest {MENU_1} lorum ipsum {MENU_2}', $matches); Output : Array ( [0] => {MENU_1 } lorum ipsum {MENU_2 } [1] => MENU_1 } lorum ipsum {MENU_2 ) ?>
EDIT:
Opgelost:
<?php
$var = 'Lorum ipsum {MENU_1} Lorum ipsum {TEXT_1} Lorum ipsum {MENU_2} Lorum ipsum ';
preg_match_all ("/{(.*?)}/",$var, $matches);
$matches = $matches[1];
echo '<pre>';
print_r($matches);
echo '</pre>';
//Output
//Array
//(
// [0] => MENU_1
// [1] => TEXT_1
// [2] => MENU_2
//)
?>
<?php $var = 'Lorum ipsum {MENU_1} Lorum ipsum {TEXT_1} Lorum ipsum {MENU_2} Lorum ipsum '; $matches = $matches[1]; //Output //Array //( // [0] => MENU_1 // [1] => TEXT_1 // [2] => MENU_2 //) ?>
|