배열 NULL 값을 제외하기


참고 : http://php.net/manual/en/function.array-filter.php



$inputKeyword = array($keyword1, $keyword2, $keyword3);


3가지 변수를 inputKeyword 배열로 생성.


그런데, $keyword2 만 값이 있고, 그 외는 NULL이라도, count($inputKeyword)은 항상 3이 나온다.


그래서 실제로 있는 값만 원할 때는


    $inputKeyword = array($keyword1, $keyword2, $keyword3);
    if($keyword1 || $keyword2 ||$keyword3) $inputKeywordFilter = array_filter($inputKeyword);


이렇게 하면, NULL 값 제외한 값이 $inputKeywordFilter에 쏙쏙 들어 가게 된다.






출처 : https://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=11575



$list = $i%2; 밑에 


$t_row = sql_fetch(" select sum(po_point) as acc_point from  $g4[point_table] where mb_id='$row[mb_id]' and po_datetime <='$row[po_datetime]' "); //추가시키기







<td align=right>".number_format($row2[mb_point])."&nbsp;</td>


대신에


<td align=right>".number_format($t_row[acc_point])."&nbsp;</td>

'tech > PHP' 카테고리의 다른 글

GET으로 값 넘길시 쿼리스트링이 깨지는 경우가 있었습니다.  (0) 2013.07.17
배열 NULL값을 제외하기  (0) 2013.04.23
text file load  (0) 2012.07.25
현재 URL 구하기  (0) 2012.06.25
open_basedir restriction in effect  (0) 2012.05.23







PHP에서 텍스트 파일을 load하는 방법은 여러 방법이 있다.



그 중에서 file_get_contents를 사용했지만 값이 정상적이지 않게 배열로 들어 가는 것을 발견




&text_1=111&&text_2=111&&text_3=111&&text_4=111&&text_5=111&&text_6=111&&text_7=111&
&text_8=1111&&text_9=222&&text_10=222&&text_11=222&&text_12=222&



  1. $file = file_get_contents('./textfile.txt', true);
  2. $convert = explode("&&", $file);


첫번째줄 개행 때문에 explode가 제대로 안된다. ㅠㅠ

지금에와서 text file 형태를 수정할수도 없는 노릇이고....



방법은........


$convert2 = preg_split('/[s]*[&][s]*/', $file);


배열원소가 하나씩 밀려나긴 하지만, 이 방법을 택하기로 했다.


지인이 추천해준 방법은 한줄씩 불러 오는 방법을 추천했다.

다음에는 이 방법을 쓰든가 해야 겠다.










  1. if(getenv(QUERY_STRING)){
  2.         $gquery = "?".getenv(QUERY_STRING);
  3. }else{
  4.         $gquery = "";
  5. }
  6. $now_url = urlencode("http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].$gquery);



출처 : 어느 블로그인지 잊어 버렸어요.






Warning: Unknown: open_basedir restriction in effect. File(/*.php) is not within the allowed path(s): (/home/juyeon/:/tmp/) in Unknown on line 0

Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

Fatal error: Unknown: Failed opening required '/*.php' (include_path='.:/home/apm/*/lib/php') in Unknown on line 0


http://koreaidc.tistory.com/24

'tech > PHP' 카테고리의 다른 글

text file load  (0) 2012.07.25
현재 URL 구하기  (0) 2012.06.25
Warning: exec() has been disabled for security reasons in ......  (0) 2012.03.22
[PHP] Warning: Cannot modify header information  (0) 2012.03.09
PHP + SQL select box  (0) 2012.02.24




결제 모듈 KCP를 연동하던 중에 테스트하던 결제창에서 잘 되다가 에러가 떴습니다.

해당 php 파일에는 exec를 사용하지 않는데 다른 클래스에서 exec를 사용하는 것 같았습니다.

소스를 잘 못 건드렸나 히스토리를 이전으로 되돌려 봤으나 같은 증상이었습니다.

파일 퍼미션 설정까지도 변경했으나 같은 증상....

알고 보니 서버 관리자분께서 보안 때문에 서버 설정 변경하셔서 갑자기 안되었습니다.

Warning: exec() has been disabled for security reasons in /home1/xxxxxxx.php on line 255

'tech > PHP' 카테고리의 다른 글

현재 URL 구하기  (0) 2012.06.25
open_basedir restriction in effect  (0) 2012.05.23
[PHP] Warning: Cannot modify header information  (0) 2012.03.09
PHP + SQL select box  (0) 2012.02.24
PHP MYSQL DB connect  (0) 2012.02.21







PHP파일을 수정 중에 Warning: Cannot modify header information 오류가 떴습니다.
구글신에서 검색 결과 FTP에서 전송 중에 문제가 있었습니다.

사용하고 있는 FTP에서 패시브 모드를 선택한 뒤 전송하면 에러가 없어집니다.

'tech > PHP' 카테고리의 다른 글

현재 URL 구하기  (0) 2012.06.25
open_basedir restriction in effect  (0) 2012.05.23
Warning: exec() has been disabled for security reasons in ......  (0) 2012.03.22
PHP + SQL select box  (0) 2012.02.24
PHP MYSQL DB connect  (0) 2012.02.21




html의 select box 리스트 내용을 mysql에서 가져와서 selected 값도 select와도 불러오면 좀 더 사용자측면에서 편리함을 제공 할 것이라고 봅니다.



예) 한 게시물의 카테고리를 사용자가 A라고 선택하고 작성했다고 가정.
그 후 게시물을 선택해서 수정 할 때는 그 게시물의 카테고리가 A라고 표시되어야 할 것입니다.

현재 게시물 테이블에 있는 카테고리 name과 전체 카테고리 name을 비교해서 같은 것이 있다면 selected를 print해서 이 게시물이 로딩되자마자 A가 선택으로 보입니다.

'tech > PHP' 카테고리의 다른 글

현재 URL 구하기  (0) 2012.06.25
open_basedir restriction in effect  (0) 2012.05.23
Warning: exec() has been disabled for security reasons in ......  (0) 2012.03.22
[PHP] Warning: Cannot modify header information  (0) 2012.03.09
PHP MYSQL DB connect  (0) 2012.02.21



<?
 $dbconnect = mysql_connect("localhost", "mysql id", "mysql password") or die(mysql_error());
 $mysql = mysql_select_db("db명") or die(mysql_error());
?>

'tech > PHP' 카테고리의 다른 글

현재 URL 구하기  (0) 2012.06.25
open_basedir restriction in effect  (0) 2012.05.23
Warning: exec() has been disabled for security reasons in ......  (0) 2012.03.22
[PHP] Warning: Cannot modify header information  (0) 2012.03.09
PHP + SQL select box  (0) 2012.02.24

+ Recent posts