Jump to content

Recommended Posts

Hey
I have a date of birth field and I wanted to implode it from it's separate fields into
one field by using implode i wanted to make it NN/NN/NNNN, so if i wanted to use
this information when changing passwords i can explode it etc.

my error:
Warning: Wrong parameter count for implode() in /home/**/func.php on line 128

my 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

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

^ 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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.