Я хочу добавить "0" перед $ _POST
$currency = $_POST['Currency']; // lets say 900
$currency = "0".$currency;
echo $currency;
Он должен был вернуть 0900, но вернул 900.
Есть идеи?
EDIT
Это полная функция
function validate(){
$ref = $this->input->post('Ref');
$shop = $this->input->post('Shop');
$amount = $this->input->post('Amount')*1000;
//$currency = $this->input->post('Currency');
//$currency = $_POST['Currency']; // lets say 900
//$currency = "0".$currency;
$currency = str_pad($_POST['Currency'],4,'0',STR_PAD_LEFT);
$query = $this->db->query("SELECT * FROM shop_validation WHERE merchant_ref = '$ref' ");
if($query->num_rows() > 0) {
$row = $query->row_array();
$posts = "";
foreach ($_POST as $name => $value) {
$posts .= $name." / ".$value;
}
$this->db->query("INSERT INTO transactions (shop,amount,currency,posts) VALUES ('$shop','$amount','$currency','$posts')");
if($row['merchant_ref'] != $ref)
{
echo "[NOTOK]";
return;
}
if($row['merchant_id'] != $shop)
{
echo "[NOTOK]";
return;
}
if(trim($row['amount']) != $amount)
{
echo "[NOTOK]";
return;
}
if($row['currency_code'] != $currency)
{
echo "[NOTOK]";
return;
}
echo "[OK]";
}
}
РЕДАКТИРОВАТЬ
Этот скрипт выполняется на платформе Codeigniter