I'm not sure if alphanumeric is the correct term but I would like to validate characters that are in a combination of strings, integers and dashes. Example: yui-4444-99. So far, i've tried intval, strcmp, ctype_alnum and preg_match but it doesnt really work.
sample:
<?php
if (ctype_alnum($string1) == ctype_alnum($string2)) {
echo "nice!";
} else {
}
my txt.file
abc-1234-99
Cedric
93482812
[email protected]
---------------------------------------------
def-4332-99
Wendy
98238432
[email protected]
Guitar
2010
Yamaha
Scratches on the side
Used
---------------------------------------------
fgh-4567-99
Wendy
98238432
[email protected]
---------------------------------------------
yui-4444-99
Wendy
98238432
[email protected]
---------------------------------------------
vbn-5624-99
jason
98238432
[email protected]
---------------------------------------------
This is how i extracted my values to diff variables.
<?php
$handle = @fopen('listings.txt', "r");
$row = 0;
$count = 0;
$line0 = [];
$line1 = [];
$line2 = [];
$line3 = [];
$line4 = [];
$line5 = [];
$line6 = [];
$line7 = [];
$line8 = [];
$line9 = [];
if ($handle) {
while (!feof($handle)) {
$store = fgets($handle, 4096);
if ($row == 10){
$row = 0;
$count++;
}
if ($row == 0)
{
$line0[] = strval($store);
}
else if($row == 1) {
$line1[] = strval($store);}
else if($row == 2) {
$line2[] = strval($store);}
else if($row == 3) {
$line3[] = strval($store);}
else if($row == 4) {
$line4[] = strval($store);}
else if($row == 5) {
$line5[] = strval($store);}
else if($row == 6) {
$line6[] = strval($store);}
else if($row == 7) {
$line7[] = strval($store);}
else if($row == 8) {
$line8[] = strval($store);}
$row++;
}
$sn = 0;
if (isset($_GET['sn'])) {
$sn=$_GET['sn'];
}
$item = count($line0);
for ($c=0; $c<$item; $c++)
{
if((intval($line0[$c]) == intval($sn))) {
echo $line0[$c],"<br>";
echo $line1[$c],"<br>";
echo $line2[$c],"<br>";
echo $line3[$c],"<br>";
echo $line4[$c],"<br>";
echo $line5[$c],"<br>";
echo $line6[$c],"<br>";
echo $line7[$c],"<br>";
echo $line8[$c],"<br>";
break;
}
}
?>
<?php
fclose($handle);
}
?>