usrec Posted February 14, 2023 Share Posted February 14, 2023 (edited) How to Split string with Dash Have Numbers field like 1-2-3-4 Would like to create new hidden Fields ie. Field1, Field2, Filed3, Field4 each containing data Field1=1 Field2=2 Field3=3 Field4=4 Edited February 14, 2023 by usrec Quote Link to comment https://forums.phpfreaks.com/topic/315913-how-to-split-string-with-dash/ Share on other sites More sharing options...
ginerjm Posted February 14, 2023 Share Posted February 14, 2023 Hidden as in HTML hidden fields? Certainly not a PHP thing. Quote Link to comment https://forums.phpfreaks.com/topic/315913-how-to-split-string-with-dash/#findComment-1605659 Share on other sites More sharing options...
Barand Posted February 14, 2023 Share Posted February 14, 2023 $numbers = '1-2-3-4'; $k = 1; foreach (explode('-', $numbers) as $n) { echo "<input type='hidden' name='Field$k' value='$n'>\n"; ++$k; } Output Quote Link to comment https://forums.phpfreaks.com/topic/315913-how-to-split-string-with-dash/#findComment-1605665 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.