我想删除字符串中的额外空格.我已经试过trim,ltrim,rtrim和其他人,但他们的工作是,甚至不尝试下面的东西.
//This removes all the spaces even the space between the words
// which i want to be kept
$new_string = preg_replace('/\s/u', '', $old_string);
Run Code Online (Sandbox Code Playgroud)
这有什么解决方案吗?
更新:-
输入字符串: -
"
Hello Welcome
to India "
Run Code Online (Sandbox Code Playgroud)
输出字符串: -
"Hello Welcome to India"
Run Code Online (Sandbox Code Playgroud) public function data()
{
if($old != $status || $prev_lat != $lat || $prev_long != $long)
{
if($status == 'Village' || 'Unknown')
{
exec_query();
}
else if($status == 'Town' || 'City')
{
exec_query();
}
}
}
public function exec_query()
{
//Some data;
}
Run Code Online (Sandbox Code Playgroud)
但每当我调用此函数时,我会得到如下错误: -
Call to undefined function exec_query()
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何在cakephp中调用函数
我的数据库中有这种日期格式
19th April 2013
Run Code Online (Sandbox Code Playgroud)
我想把它转换成
2013-04-19
Run Code Online (Sandbox Code Playgroud)
我用过if,else条件,BUt它变得太长而复杂.是否有任何内置函数?
我正在尝试使用 php 命令连接到 FTP。但是当我尝试登录时出现以下错误
Warning: ftp_login(): Non-anonymous sessions must use encryption
Run Code Online (Sandbox Code Playgroud)
我尝试过的代码:
ftp_connect($ftp_server)
ftp_get($ftp_conn, $local_file, $server_file, FTP_ASCII)
Run Code Online (Sandbox Code Playgroud)
尽管它是通过 FileZilla 连接的。不确定该错误意味着什么。谢谢
我对cakephp有一个简单的疑问,它可能也很傻.
在cakephp中编写查询: -
1.$output1 = $this->Modelname->query("Select * from tablename");
2.$output2 = $this->Modelname->query("Update tablename set .....");
Run Code Online (Sandbox Code Playgroud)
当我执行第一个查询,即$ output1.它完美运行.但是,如果我运行$ output2它将无法正常运行
可能是什么问题?