Php removes space elements in the array. for all prawn programmers: & nbsp; I am a beginner PHP rookie. for more information, see <g id = "1"> </g>.
Prawn programmers:
I am a beginner PHP Cainiao. now I have a question:
As needed by the company, I downloaded and installed a Roundcube Wemail, and wrote some necessary plug-in programs in it according to the company's requirements. When writing forward mail addresses, I write the addresses to be forwarded in a variable, and then use the explode () function to separate them into array elements with the carriage return symbol, however, I found that the last element is always empty after it is saved, so how can I not delete it? this problem has plagued me for three days. Here are some related procedures:
Fields obtained from the database
$ User_saved_forward_email = forwardemail_qry (); // create a record set
$ Field_id = 'forward _ email_address ';
If ($ user_saved_forward_email! = Null)
{
$ Myemail = '';
$ Email_arr = explode (";", $ user_saved_forward_email [1]); // if forwarding is permitted, separate and display each element from the field of the data table ";"
Foreach ($ email_arr as $ k => $ v)
{
If ($ k = count ($ email_arr-1 ))
{
$ Myemail = $ myeamil. $ v;
} Else {
$ Myemail = $ myemail. $ v. chr (10 );
}
}
Convert the string input at the front end into an array, separate each element in the array with chr (10), and write it into the database ";".
$ Forward_email_address = get_input_value ('forward _ email_address ', RCUBE_INPUT_POST );
// Convert all forwarded addresses into arrays
$ Forward_email_address_Array = explode (chr (10), $ forward_email_address );
// Count the number of array elements $ aaa;
$ Forward_address = array_unique ($ forward_email_address_Array); // obtain non-repeated array elements
If (count ($ forward_address )! = Count ($ forward_email_address_Array) // if there are duplicate emails
{
$ Forward_count = count ($ forward_address );
$ Rcmail-> output-> command ('display _ message', $ this-> gettext ('forward _ repeat'), 'Confirmation ');
Return FORWARDEMAIL_ERROR;
}
$ Email_count = count ($ forward_address );
$ Forward_email_address = null; // The initial value is NULL.
For ($ I = 0; $ I <= ($ email_count-1); $ I ++) // traverse all array elements
{
If (strlen (trim ($ forward_address [$ I])> 2) // if the element is not empty
{
If (ereg ("^ [_\. 0-9a-z-] + @ ([0-9a-z] [0-9a-z-] + \.) + [a-z] {2, 3} $ ", trim ($ forward_address [$ I]) // if the email format is correct
{
If ($ forward_address [$ I] = $ _ SESSION ['username']) // if the user forwards the message, an error message is returned.
{
$ Rcmail-> output-> command ('display _ message', $ this-> gettext ('forward _ self '), 'Confirmation ');
Return FORWARDEMAIL_ERROR;
} Else // assign a value to the $ forward_email_address variable and add ";"
{
$ Forward_email_address = trim ($ forward_email_address. $ forward_address [$ I]). ";";
}
}
Else // if the element does not conform to the format, an error message is returned!
{
$ Forward_email_enabled = "N ";
$ Rcmail-> output-> command ('display _ message', $ this-> gettext ('forward _ incorrect '), 'Confirmation ');
Echo "That Email Format is Wrong! ";
Return FORWARDEMAIL_ERROR;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service