Copy
else if( strpos($content, "단어") !== false )
{
echo <<< EOD
{
"message": {
"text": "내용"
}
}
EOD;
}
else if( strpos($content, "단어") !== false ) 여기에서 여러단어를 사용하고 싶은데요
예를들면
else if( strpos($content, "단어","단어2",단어3","단어4") !== false )
이렇게 사용할려면 어떻게 해야되나요?
|
답변 1개 / 댓글 5개
채택된 답변
+20 포인트
2017-12-20 (수) 22:01:07
function strpos_arr($content, $word) {
return preg_match( "/$word/", $content );
}
echo strpos_arr($content, '단어1|단어2');
답변에 대한 댓글 5개
별을따는소년
2017-12-20 (수) 22:05:34
2017-12-20 (수) 23:02:31
// if문 밖에 위치
function strpos_arr($content, $word) {
return preg_match( "/$word/", $content );
}
else if ( strpos_arr($content, '단어1|단어2') )
function strpos_arr($content, $word) {
return preg_match( "/$word/", $content );
}
else if ( strpos_arr($content, '단어1|단어2') )
별을따는소년
2017-12-20 (수) 23:15:11
else if( $content == "시작")
{
echo <<< EOD
{
"message": {
"text": "인사말"
}
}
EOD;
}
function strpos($content, $word) {
return preg_match( "/$word/", $content );
}
else if ( strpos($content, '단어1|단어2') !== false )
{
echo <<< EOD
{
"message": {
"text": "내용"
}
}
EOD;
}
이렇게 적었는데요 에러가 발생하는데요?
이게 맞는거죠?
{
echo <<< EOD
{
"message": {
"text": "인사말"
}
}
EOD;
}
function strpos($content, $word) {
return preg_match( "/$word/", $content );
}
else if ( strpos($content, '단어1|단어2') !== false )
{
echo <<< EOD
{
"message": {
"text": "내용"
}
}
EOD;
}
이렇게 적었는데요 에러가 발생하는데요?
이게 맞는거죠?
2017-12-20 (수) 23:33:32
함수로 만들어 드렸는데 적용을 어려워 하시네요.
else if( strpos($content, "단어") !== false )
=>
else if ( preg_match('/단어1|단어2/', $content) )
else if( strpos($content, "단어") !== false )
=>
else if ( preg_match('/단어1|단어2/', $content) )
답변을 작성하려면 로그인이 필요합니다.
return preg_match( "/$word/", $content );
}
echo strpos_arr($content, '단어|단어2ㅣ단어3');
{
echo <<< EOD
{
"message": {
"text": "내용"
}
}
EOD;
이렇게 하면되는건가요? 에러가나는거같에서요