본문 바로가기

PHP/PHP함수

str_replace

<?php

header("Content-Type: text/html; charset=UTF-8");



$offcolor = ["대림","임직원","금품"];

$content = "대림산업과 하청 계약을 맺었던 A 건설의 지출 결의서입니다. 하남 현장 격려비로 500만 원이 나갔다고 쓰여 있습니다.


A 건설 측이 일을 주는 대림산업 관계자들에게 수백만 원씩 돈을 줬다며 보여준 근거임직원입니다.


또 대림산업 임직원들은 발주처인 서울시와 LH 측에 로비가 필요하다며 금품 상납까지 요구했다고 말합니다.";


$content = str_replace($offcolor, '[나냐나]', $content);


echo $content;



$phrase  = "You should eat fruits, vegetables, and fiber every day.";

$healthy = array("fruits", "vegetables", "fiber", "every", "day");

$yummy   = array("pizza", "beer", "ice cream");

$yummy   = "pizza";


$newphrase = str_replace($healthy, $yummy, $phrase);


echo $newphrase;

?>



'PHP > PHP함수' 카테고리의 다른 글

spl_autoload_register  (0) 2017.12.12
array_walk  (0) 2017.12.03
in_array, array_key_exists  (0) 2017.11.25
strpos(),strrpos()와 strstr(),strrchr() 함수이용  (0) 2017.11.25
array_push, count, append  (0) 2017.11.24