PHP substr 取得某一區段文字 字串分割

<?php

$rest = substr(“abcdef”, 0 , 1); // returns “a”
$rest = substr(“abcdef”, 2 , 2); // returns “cd”
$rest = substr(“abcdef”, -1); // returns “f”
$rest = substr(“abcdef”, -2); // returns “ef”
$rest = substr(“abcdef”, -3, 1); // returns “d”

$rest = substr(“abcdef”, 0, -1);  // returns “abcde”
$rest = substr(“abcdef”, 2, -1);  // returns “cde”
$rest = substr(“abcdef”, 4, -4);  // returns false
$rest = substr(“abcdef”, -3, -1); // returns “de”
?>

原文

http://us2.php.net/manual/en/function.substr.php[……]

閱讀更多

統一編號 英文

公司統一編號 = Company Tax ID 
統一編號 = VAT number
統一編號 = Uniform Serial Number
統一編號 = Unified Business No.

Value Added Tax (VAT)
Business-> General
Business-> International Business
Business-> Accounting
Governmental-> US Government

一般秀 ” VAT number ” 
經濟部的網站上秀 Unified Business No. 

Business Registration Code 或 Business Registration number
or Company Registration Code or Company Regsitration number [……]

閱讀更多

PHP 使用 nusoap 連接 call webservice function sample (支援utf-8)

下儎 nusoap-0.9.5
http://sourceforge.net/projects/nusoap/

include(‘nusoap-0.9.5/lib/nusoap.php’);

// 顯示錯誤
ini_set(“display_errors”, “On”);
error_reporting(E_ALL & ~E_NOTICE);

$xml = <<<XML
<?xml version=”1.0″ encoding=”utf-8″ ?>
<ORDER_DOC>
<ORDER>
<ECNO>263</ECNO>
<ODNO>00000000038</ODNO>
<STNO>F001558</STNO>
<AMT>500</AMT>
</ORDER>
<ORDERCOUNT>
<TOTALS>1</TOTALS>
</ORDERCOUNT>
</ORDER_DOC>
XML;
//<?

// 創建一個soapclient對象,參數是server的WSDL
$client = new soapclient(‘https://www.yourdomain.com/webservice/service.asmx?wsdl’, ‘wsdl’);

// 設定utf-8編碼
$client->soap_defencoding = ‘UTF-8’;
$client->decode_utf8 = false;
$client->encode_utf8 = true;

//錯誤訊息
if ($err=$client->getError()) {
  print “ERROR: $err”;
}

// 呼叫遠端函數
$result = $client->call(‘ORDERS_ADD’,array(‘xmlStr’=>$xml));

// 接收回應
if ($client->fault)
{
echo ‘<h2>Fault</h2><pre>’;
print_r($result);
echo ‘</pre>’;
}
 else
 {

// Check for errors
$err = $client->getError();
if ($err)
{
// Display the error
echo ‘<h2>Error</h2><pre>’ . $err . ‘</pre>’;
}
else
{
// Display the result
echo ‘<h2>Result</h2><pre>’;
print_r($result);
echo ‘</pre>’;
}
}

SAMPLE
https://drive.google.com/file/d/0B0WjmRBDYP2fM1FhaFNSb3hYbUE/edit?usp=sharing

[……]

閱讀更多

php array to query string

<?php
$data 
= array(‘foo’‘bar’‘baz’‘boom’‘cow’ => ‘milk’‘php’ =>‘hypertext processor’);

echo http_build_query($data) . “n”;
echo 
http_build_query($data‘myvar_’);?>
output

0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor
myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor

原文
http://www.php.net/manual/en/function.http-build-query.php

[……]

閱讀更多