I have created the following array.
$a_random = array( '<random-all>', '<random>', '<random-all-or>', '<random-1>',
'<random-all-1>','<random-all-2>','<random-all-3>','<random-all-4>','<random-all-5>','<random-all-6>',
'<random-all-7>','<random-all-8>','<random-all-9>','<random-all-10>',
'<random-or-1>','<random-or-2>','<random-or-3>','<random-or-4>','<random-or-5>','<random-or-6>',
'<random-or-7>','<random-or-8>','<random-or-9>','<random-or-10>'
);
However, when I print_r the array none of the values have been inserted into the array.
It has to do with the '<' '>' characters.
I need those specific values with the '<' '>' to be in the array. How can I force the array to populate them?
php array ignoring values
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: php array ignoring values
It is creating the array with < and > but your browser interprets them as HTML tags just like <body> etc, so it doesn't display them. Do a view source on your browser and you will see them. You need to convert them to the HTML entities for the browser to display them. You could probably do this:
Code: Select all
print_r(array_map('htmlentities', $a_random));mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: php array ignoring values
That makes sense but it is making it very difficult to trouble shoot an issue I'm having.
The code that follows is behaving like the array is empty. That's why I assumed the array was really empty.
The code that follows is behaving like the array is empty. That's why I assumed the array was really empty.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: php array ignoring values
Make your own function to do this and also save typing. I would also wrap it in pre tags so that you get it nicely formatted in the browser(tabs, newlines, etc.):kewpe20 wrote:That makes sense but it is making it very difficult to trouble shoot an issue I'm having.
The code that follows is behaving like the array is empty. That's why I assumed the array was really empty.
Code: Select all
function pre($var) {
echo '<pre>';
print_r(array_map('htmlentities', $var));
echo '</pre>';
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.