我写了一个脚本以这种方式从字符串中删除R $:
$money ="R$ 100,00";
$charactersToBeRemoved = array("R", "$", " ");
$changedValue = str_replace($charactersToBeRemoved, "", $money);
这个脚本在主脚本上运行正常,但如果我为它创建一个函数,如:
function removeDollar($x) {
$charactersToBeRemoved = array("R", "$", " ");
$changedValue = str_replace($charactersToBeRemoved, "", $x);
return $changedValue;
}
$money = "R$100,00";
$newValue = removeDollar($money);
echo $newValue;
$newValue
仍显示R $ 100,00。
注意:
此函数是在functions.php文件中创建的,其中include函数已包含在主脚本中。
我真的不知道自己做错了什么。
答案 0 :(得分:0)
正常工作
import UIKit
class ViewController: UIViewController, UINavigationControllerDelegate, UIViewControllerTransitioningDelegate {
override func viewDidLoad() {
if transitioningDelegate != nil {
print("Should do something...")
print(transitioningDelegate)
} else {
print("Transitioing Delegate set to nil")
}
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.navigationController?.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
let customPresentAnimationController = CustomPresentAnimationController()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print("doing our custom transition")
print(segue.destination)
let destination = segue.destination
destination.transitioningDelegate = customPresentAnimationController
}
}
您可以在此PHP Sandbox example
中查看上述代码并且工作得很好(在你的例子中)
Transitioing Delegate set to nil
doing our custom transition
<moduleView.ViewController: 0x7fe427f09a40>
Should do something...
Optional(<moduleView.CustomPresentAnimationController: 0x60800002e980>)
您可以在此PHP Sandbox example
中查看上述代码如果您需要检查所有字符串字符
function removeDollar($x) {
$charactersToBeRemoved = array("R", "$", " ");
$removeTo = array("","","");
$changedValue = str_replace($charactersToBeRemoved, $removeTo, $x);
return $changedValue;
}
$money = "R$100,00";
$newValue = removeDollar($money);
echo $newValue;
// output 100,00
您可以在此PHP Sandbox example
中查看上述代码