Home > Backend Development > PHP Tutorial > PHP array prompt Notice: Undefined offset solution_PHP tutorial

PHP array prompt Notice: Undefined offset solution_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:56:51
Original
2764 people have browsed it

When we use arrays, we often encounter that the array does not exist, causing a Notice: Undefined offset error when we store array[100]. Let me introduce to you how to solve this problem

Example:

The input result is
The code is as follows
 代码如下 复制代码

$array[1] ='www.bKjia.c0m';

echo $array[0] ;

Copy code

$array[1] ='www.bKjia.c0m';

echo $array[0] ;

 代码如下 复制代码

echo isset($array[0])?$array[0]:'数组未定义';

Notice: Undefined offset: 1 in D:wwwrootwraskseo404.php on line 5 Let’s look at the solution

Solving this problem is as simple as

The code is as follows Copy code
echo isset($array[0])?$array[0]:'Array is undefined'; This solves this problem very well.
http://www.bkjia.com/PHPjc/632118.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632118.htmlTechArticleWhen we use arrays, we often encounter that the array does not exist, causing us to store array[100]. Notice: Undefined offset error, let me introduce how to solve this problem...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template