xyn Posted October 23, 2006 Share Posted October 23, 2006 HeyI have a date of birth field and I wanted to implode it from it's separate fields intoone field by using implode i wanted to make it NN/NN/NNNN, so if i wanted to usethis information when changing passwords i can explode it etc.my error:Warning: Wrong parameter count for implode() in /home/**/func.php on line 128my code:[code=php:0]$doba = MakeSafe($_POST[dobd]);$dobm = MakeSafe($_POST[dobm]);$doby = Makesafe($_POST[doby]);$Dob = implode('/', '$doba','$dobm','$doby');[/code] Link to comment https://forums.phpfreaks.com/topic/24874-implode-count-ll/ Share on other sites More sharing options...
.josh Posted October 23, 2006 Share Posted October 23, 2006 $Dob = "$doba/$dobm/$doby"; Link to comment https://forums.phpfreaks.com/topic/24874-implode-count-ll/#findComment-113362 Share on other sites More sharing options...
kenrbnsn Posted October 23, 2006 Share Posted October 23, 2006 The [url=http://www.php.net/implode]implode()[/url] function takes an array as the second paramter, not strings. You can achieve the what you're looking for in two ways:1) [code]<?php$doba = MakeSafe($_POST[dobd]);$dobm = MakeSafe($_POST[dobm]);$doby = Makesafe($_POST[doby]);$Dob = implode('/', array($doba,$dobm,$doby));?>[/code]2)[code]<?php$tmp = array();$tmp[] = MakeSafe($_POST[dobd]);$tmp[] = MakeSafe($_POST[dobm]);$tmp[] = Makesafe($_POST[doby]);$Dob = implode('/', $tmp);?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/24874-implode-count-ll/#findComment-113367 Share on other sites More sharing options...
.josh Posted October 23, 2006 Share Posted October 23, 2006 ^ that's a whole lot of extra work for simply making a string of values seperated by a / ...sure, it might be all fancy looking, but again, this does the same thing:[code]<?php$doba = MakeSafe($_POST[dobd]);$dobm = MakeSafe($_POST[dobm]);$doby = Makesafe($_POST[doby]);$Dob = "$doba/$dobm/$doby";?>[/code] Link to comment https://forums.phpfreaks.com/topic/24874-implode-count-ll/#findComment-113370 Share on other sites More sharing options...
kenrbnsn Posted October 23, 2006 Share Posted October 23, 2006 Yes, I know, but the OP asked about using the [b]implode()[/b] function, so I gave him examples using the function.Of course your example can be reduced to:[code]<?php$dob = MakeSafe($_POST['dobd']) . '/' . MakeSafe($_POST['dobm']) . '/' . MakeSafe($_POST['doby']);?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/24874-implode-count-ll/#findComment-113375 Share on other sites More sharing options...
.josh Posted October 23, 2006 Share Posted October 23, 2006 okay fine how about i one up you then!if the only posted variables you have are those 3, then all you have to do is this:$dob = implode('/',$_POST);oh snap! ;D Link to comment https://forums.phpfreaks.com/topic/24874-implode-count-ll/#findComment-113385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.