Toon Posted December 10, 2008 Share Posted December 10, 2008 Example: Remplace [name] in a text variable by $_POST[$name]. So all things between "[]" in this text variable will be remplaced by that PHP post variable of the name between the two "[]". 2nd example: So if the variable would contains a [phone_numer] somewhere this will be geplaces in PHP by $_POST[$phone_numer]. I hope i have been clear and that you guys can help me! Thanks a lot, Toon Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 10, 2008 Share Posted December 10, 2008 I would first like to know why you would never need to do this. Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 10, 2008 Share Posted December 10, 2008 It can be done by php session but what for ...... ???? Quote Link to comment Share on other sites More sharing options...
dezkit Posted December 10, 2008 Share Posted December 10, 2008 Use preg_replace and RegEx Quote Link to comment Share on other sites More sharing options...
Toon Posted December 10, 2008 Author Share Posted December 10, 2008 Hello, Thanks for the quick replys! This where i need it for: I have a form wich will have to be multilanguage and easy to modify for the website owner. The text like "Dear [name], Thanks for..." will aprear when a visitor has finished filling in the form. I have already tryed with preg_replace but could'nt make it work. I hope someone is into preg_replace around here. Thanks for your help, Toon Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 10, 2008 Share Posted December 10, 2008 lol you can always um use an array or a session or something... but $_POST['field'] << That comes from a FORM, you can't change that unless you change the field name in a form. but....why need this? Quote Link to comment Share on other sites More sharing options...
corbin Posted December 10, 2008 Share Posted December 10, 2008 Hello, Thanks for the quick replys! This where i need it for: I have a form wich will have to be multilanguage and easy to modify for the website owner. The text like "Dear [name], Thanks for..." will aprear when a visitor has finished filling in the form. I have already tryed with preg_replace but could'nt make it work. I hope someone is into preg_replace around here. Thanks for your help, Toon You could just use str_replace. Example: <?php $some_array = array('name' => 'Corbin', 'foo' => 'bar'); $str = "Hello [name]. Did you know that foo = [foo]?"; $tmp = $str; foreach($some_array $k => $v) { $tmp = str_replace("[{$k}]", $v, $tmp); } echo $tmp; Quote Link to comment Share on other sites More sharing options...
DarkWater Posted December 10, 2008 Share Posted December 10, 2008 It can be done by php session but what for ...... ???? What? @thread starter: Why don't you just directly interpolate the variables...? Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 10, 2008 Share Posted December 10, 2008 user put there name in the dear username field now $name=$username Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 It can be done by php session but what for ...... ???? What? @thread starter: Why don't you just directly interpolate the variables...? Agreed, whats the point of making so complicated lol? Quote Link to comment Share on other sites More sharing options...
Toon Posted December 11, 2008 Author Share Posted December 11, 2008 Thanks to every one, I made it with Corbin's code! I wish every one a great day from France, Toon Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 11, 2008 Share Posted December 11, 2008 Thanks to every one, I made it with Corbin's code! I wish every one a great day from France, Toon Please marked it as solve, i like it when everything is greener around here/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.