2026, 새로운 도약을 시작합니다.

개행 문자열 자르기 채택완료


예..안녕하세요.

사과 300<엔터>
귤 4000<엔터>
배 4000<엔터>
포도 5000<엔터>
수박 1000<엔터>
감 5000<엔터>

이렇게 문자열을 입력 받아 $aaa = explode(' ',$cont); 로 했더니 개행으로 나누어 지지 않는군요.

어떻게 하여야 하는지 좀 조언 좀 바랍니다.

답변 1개

채택된 답변
+20 포인트
&nbsp; $aaa = 'variable1 variable2 variable3 variable4 variable5';


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;


&nbsp; $pieces = explode(" ", $aaa);


&nbsp;


&nbsp; while (list ($key, $val) = each ($pieces))


&nbsp; &nbsp; &nbsp; &nbsp; echo "$key => $val
";


&nbsp;


&nbsp; // OR


&nbsp;


&nbsp; $aaa = 'variable1|variable2|variable3|variable4|variable5';


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;


&nbsp; $pieces = explode("|", $aaa);


&nbsp;


&nbsp; while (list ($key, $val) = each ($pieces))


&nbsp; &nbsp; &nbsp; &nbsp; echo "$key => $val
";


&nbsp;


&nbsp; // so many possibilities ....
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고