I have a question. To make things more clear, I will give an example:
Values are submited in a form. I have:
Value1: Blanc
Value2: Titanium
Value3: 100
Value4: 150
Value5: China
I want to get a value 6 that has this structure:
BLTIT-100150-CH
Value6 has: (2 chars from value1) + (3 chars from value5) +(-)+(value3+value4 +(-)+(2 chars of value5).
Is there way to make that with PHP Or JavaScript?
In PHP:
Of course, this assumes your variables are set locally. If you’re getting them straight from the POST, you need
$_POST['Value1']instead of$Value1, etc.Look up
substr– it takes a subsection of a string (known as a substring), given a starting point and a length.:http://php.net/manual/en/function.substr.php
The
.is the PHP string concatenation operator – it joins two strings together.strtoupperconverts a string to uppercase (see http://php.net/manual/en/function.strtoupper.php)