scripting - PHP preg_match meaning and issue -
currently have code:
<?php if (isset($_get['id'])) { $itemid = $_get['id']; $search = "$itemid"; $query = ucwords($search); $string = file_get_contents('http://clubpenguincheatsnow.com/tools/newitemdatabase/items.php'); if($itemid=="") { echo "please fill out form."; } else { $string = explode('<br>',$string); foreach($string $row) { preg_match('/^(\d+)\s=\s(\d+)\s=\s(\d+)\s=\s(\d+)/', trim($row), $matches); if(strstr($matches[1], $query)) { echo "<a href='http://clubpenguincheatsnow.com/tools/newitemdatabase/info.php?id=$matches[2]'>"; echo $matches[1]; echo "</a><br>"; } } if($matches[1]=="") { echo "item not exist!"; } } } else { echo "item not exist!"; } ?>
what want know section mean? preg_match('/^(\d+)\s=\s(\d+)\s=\s(\d+)\s=\s(\d+)/', trim($row), $matches);
/^(\d+)\s=\s(\d+)\s=\s(\d+)\s=\s(\d+)/
part wondering about.
also, issue have been having how can allow use numbers too? because have file has data (http://clubpenguincheatsnow.com/tools/newitemdatabase/items.php) , want grab everything, names numbers.
how do though? please me! highly appreciated!
that regular expression.
the '^' matches beginning of string.
the '\d' matches character not digit.
the '\d' matches digit.
the '\s' matches whitespace.
the plus sign means previous character can occur multiple times.
so match lines in file, except last comma.
blue = 1 = no = 20
that line match regex.
about last question allow numbers too, use this:
/^(.+)\s=\s(\d+)\s=\s(\d+)\s=\s(\d+)/
Comments
Post a Comment