Bu birleştirme php dize beni çıldırtıyor!

0 Cevap php

Ben bir $ _POST önünde bir "0" başa eklemek istiyorum

$currency = $_POST['Currency']; // lets say 900
$currency = "0".$currency;
echo $currency;

Bu 0900 döndü olmalıydı ama 900 döndürür.

Herhangi bir fikir?

EDIT

Bu tam fonksiyon olduğunu

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]";

        }


    }

DÜZENLEME

Codeigniter çerçeve üzerinde çalışan bu script

0 Cevap