Reputation: 1248
I know there must be a better way of writing this i just can not find it or am not asking the right question.
How would i wright multiple str_replace in one statement?
Here is my code
function create() {
if(array_key_exists('createFolder',$_POST)){
$data = array(
'folderName' => $this->input->post('folderName')
// 'time' => date('Y-m-d H:i:s',now())
);
$data = str_replace(' ', '_', $data);
$data = str_replace('.', '_', $data);
$data = str_replace('?', '_', $data);
$datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
$time = time();
// $data = str_replace(' ', '_', $data);
$this->index_model->createFolder($data, $datestring, $time);
}
$this->foldercreated();
}
Upvotes: 1
Views: 376
Reputation: 6353
Use an array like $data = str_replace(array(' ', '.', '?'), '_', $data);
Upvotes: 2
Reputation: 12675
you can use an array:
$data = str_replace(array(' ', '.', '?'), '_', $data);
Upvotes: 3