The title may be sound confusing so here is the code to explain clearly.
I wrote the following code in a PHP script
$options=array(
CURLOPT_URL => 'http://site2sms.com/userregistration_next.asp',
CURLOPT_REFERER => 'http://site2sms.com/UserRegistration_Next.asp',
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31',
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => http_build_query($post_fields)
);
But, when the dump the array using var_dump function here is what I got
array (size=5)
10002 => string 'http://site2sms.com/userregistration_next.asp' (length=45)
10016 => string 'http://site2sms.com/UserRegistration_Next.asp' (length=45)
10018 => string 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31' (length=108)
47 => int 1
10015 => string 'action=UserCreate&txtFullName=fdsf&genderCombo=Male&birth_day=2&birth_month=12&birth_year=2013&txtEmail=fdsf%40dssad&ProfessCombo=1&StateCombo=Delhi&txtMobileNum=4234&cityCombo=223&Submit=Register' (length=196)
Clearly, the value of constant CURLOPT_URL is replaced by 10002 in its dump. So, I replaced the original array by this
$options=array(
'CURLOPT_URL' => 'http://site2sms.com/userregistration_next.asp',
'CURLOPT_REFERER' => 'http://site2sms.com/UserRegistration_Next.asp',
'CURLOPT_USERAGENT' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31',
'CURLOPT_POST' => TRUE,
'CURLOPT_POSTFIELDS' => http_build_query($post_fields)
);
to get this dump value
array (size=5)
'CURLOPT_URL' => string 'http://site2sms.com/userregistration_next.asp' (length=45)
'CURLOPT_REFERER' => string 'http://site2sms.com/UserRegistration_Next.asp' (length=45)
'CURLOPT_USERAGENT' => string 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31' (length=108)
'CURLOPT_POST' => boolean true
'CURLOPT_POSTFIELDS' => string 'action=UserCreate&txtFullName=fdsf&genderCombo=Male&birth_day=2&birth_month=12&birth_year=2013&txtEmail=fdsf%40dssad&ProfessCombo=1&StateCombo=Delhi&txtMobileNum=4234&cityCombo=485&Submit=Register' (length=196)
Now, I am getting an error Warning: curl_setopt_array(): Array keys must be CURLOPT constants or equivalent integer values. So, How can I tweak the array so that dumping array shows constant name not value and when used with curl_setopt_array it should work nicely. I am looking for some function that can be used a step earlier than curl_setopt_array function so that it can make necessary changes to array. If it is not possible through PHP built in functions please suggest me how to create this function manually.
constant()for passing its keys to_setopt.for eachloop for it.