So I am having a bit of an issue getting results from a query.
<?php
$query = "SELECT re_diag_DL
FROM game_win_regex
WHERE game_id = 1
LIMIT 1";
$con = mysqli_connect("localhost",'root','','game');
$result = mysqli_query($con,$query);
$row = mysqli_fetch_all($result,MYSQLI_BOTH);
echo $row['re_diag_DL'][0];
?>
The fields content is a regular expression:
((?<!z,)[1]
But the echo is giving
((?
It is definitely messing with the array structure, a print_r() gives
Array ( [0] => Array ( [0] => ((?
I intend to use this result within a preg_match_all. Any help on this matter would be greatly appreciated.
Most likely the echoing is being done in a web browser and the browser is expecting a tag starting with <
.
Check the source code of the page, not the rendered page.
By the way, you can safely use the result of $row['re_diag_DL'][0]
in a preg_match_all
as it is merely a display issue.
To view in the browser use htmlentities(). As Mosty Mostacho states, the browser treats < and > as HTML tags and doesn't display them as text.
Place
header("Content-type: text/plain");
in the begin of php-file. Or view source of HTML document. Or wrap in PRE tag. You regexp was treated by browser as html tag.