简体   繁体   English

消除表数据空间

[英]Eliminate table data space

My column 'email' is auto filled by columns 'firstname'.'lastname' eg: 'John' 'Doe' ------> john.doe@example, but some people have multiple first names like: 'John Michael' 'Doe' -------> john michael.doe@example, how do I close that space in the first name?我的“email”列由“firstname”.“lastname”列自动填充,例如:“John”“Doe”------> john.doe@example,但有些人有多个名字,例如:“John Michael” ' 'Doe' -------> john michael.doe@example,我如何关闭名字中的那个空间?

在此处输入图片说明

Here is the code for that specific row:这是该特定行的代码:

<td> <?=strtolower($row['fname'])?>.<?=strtolower($row['lname'])?‌​>@cubao.sti.edu </td>

试试这个: str_replace([' '], [''], $formValues['firstname']).$formValues['lastname'])

Elimination of white space :消除空白:

$clean_data = preg_replace('#[^a-z0-9]#i', '', $true_value_got_from_user);

In this case you can put $first_name in preg replace and you will get clean data as output在这种情况下,您可以将 $first_name 放入 preg replace 中,您将获得干净的数据作为输出

Additionally : This will also replace unwanted data like special characters and anything else than alphabets and special characters like (. , " " [] {} etc. ) which are not really in first name.另外:这也将替换不需要的数据,如特殊字符以及除字母和特殊字符(如 (. , " " [] {} 等)以外的任何其他内容,这些数据并不是真正的名字。

If you ever wanted that first name should not contain numeric like 0-9 then delete 0-9 statement and your output will be a clean alphabet string.如果你曾经希望名字不应该包含像 0-9 这样的数字,那么删除 0-9 语句,你的输出将是一个干净的字母字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM