Created
October 26, 2015 04:44
-
-
Save s-hiroshi/22655428075c479b7187 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* クエリ文字列構築 | |
* | |
* @param array $params key/value pair | |
* | |
* @return array クエリ文字列 | |
*/ | |
public static function get_end_point( $params ) { | |
// クエリ文字列構築 | |
$query = array(); | |
if ( isset( $params['key1'] ) && empty( $params['key1'] ) ) { | |
array_push( $query, 'key1=' . $params['key'] ); | |
} | |
if ( isset( $params['key2'] ) && empty( $params['key2'] ) ) { | |
array_push( $query, 'key2=' . $params['key2'] ); | |
} | |
if ( isset( $params['key3'] ) && empty( $params['key3'] ) ) { | |
array_push( $query, 'key3=' . $params['key3'] ); | |
} | |
$queryStr = implode( '&', $query ); | |
if ( ! empty( $queryStr ) ) { | |
$queryStr = '?' . $queryStr; | |
} | |
return $queryStr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment