Hi, I found the code here, it's excately what i am looking for, ie8 give this error "Notice: Undefined offset: 49 in.." which is this line "if ($num_of_chars[49]==$required)", i'm a newbie, i don't know how to overcome this error, so can someone please help me out?
thanks, -
$string = "one two three";
-
$word_array = explode(" ",$string);
-
for ($i=count($word_array); $i>=1; $i--)
-
{
-
$word = $i == 1 ? " word" : " words";
-
echo "Strings containing combination of ".$i.$word.":<br>";
-
-
$flags = array();
-
$combination_flags = get_combination_flags(count($word_array), $i);
-
$flags_groups = explode(",",$combination_flags);
-
foreach ($flags_groups as $val)
-
{
-
$temp = chunk_split($val,1,".");
-
array_push($flags, explode(".", substr($temp,0,(strlen($temp)-1))));
-
}
-
for ($j=0; $j<count($flags); $j++)
-
{
-
$new_string = "";
-
for ($k=0; $k<count($word_array); $k++)
-
$new_string .= $flags[$j][$k] ? " ".$word_array[$k] : "";
-
trim ($new_string);
-
echo $new_string."<br>";
-
}
-
echo "<br>";
-
}
-
-
function get_combination_flags($total, $required)
-
{
-
$flag_array = array();
-
$bin = "";
-
for ($i=0; $i<$total; $i++)
-
$bin .= "1";
-
$dec = bindec($bin);
-
for ($i=0; $i<=$dec; $i++)
-
{
-
$num_of_chars = count_chars(decbin($i), 1);
- if ($num_of_chars[49]==$required)
-
{
-
$temp = decbin($i);
-
$length = strlen($temp);
-
$pre = "";
-
if ($length<$total) for ($j=$length; $j<$total; $j++) $pre .= "0";
-
$temp = $pre.$temp;
-
array_push($flag_array,$temp);
-
}
-
}
-
return implode(",",$flag_array);
-
}
-
?>
-
1 5155 zorgi 431
Recognized Expert Contributor
All that means is that your error_reporting in your php.ini file is set to report notices. There is two ways around this problem. First one is to set your error_reporting so it doesn't report notices:
error_reporting = E_ALL & ~E_NOTICE
that way you turn off all the notices.
OR
You can use extra condition in your if statement: -
if ((isset($num_of_chars[49]))&&($num_of_chars[49] == $required))
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
I just switched error_reporting to ALL so I could debug my site. I got
a huge page full of errors. One of the most common was that in my
arrays I'm using undefined offsets and indexes. These still work fine,
but with error reporting at all they are marked as errors. Why? What
am I doing wrong?
www.monkeyclaus.org
|
by: Steven |
last post by:
Hi All,
I am moving some php code from a Linux machine to a Windows 2000 machine
with the code belowe I get the following error :
Notice: Undefined offset: 1 in c:\inetpub\wwwroot\test.php on line 5
1) reset($kolom1);
2) while(list($cat,$lnk) = each($kolom1)){
3) kop($cat);
|
by: google |
last post by:
Hello,
I'm having major problems trying to get my head round this problem.
I'm trying to generate an error free script, however, I still cannot
sort out this loop.
I get a "Notice: Undefined offset: 24 in
c:\inetpub\wwwroot\classes\file.php on line 348"
|
by: Richard Lawrence |
last post by:
Hi there,
I'm having a problem with PHP which I'm not sure how to best solve.
Here is the code:
$fp = fopen("comments.txt", "r");
while(!feof($fp))
{
$line = fgets($fp, 1024);
list($key, $value) = explode(":", $line, 2);
|
by: nicy12 |
last post by:
Hi! my name is Peter. iam working on the php platform.
while trying to run and compile a program i get the undefined offset error
iam nto much familiar with this error . Please help me . Thanks in advance.
Error: Undefined offset: 0 in /es/ePrintsStats/includes/inc.html.cumulative_usage.es.php on line 16
The code:
<?php
$current_year = date("Y");
$last_year = date("Y")-1;
| |
by: number1yan |
last post by:
Can anyone help me,
i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is:
Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email...
|
by: simple12 |
last post by:
Hello
I have a script which have the facility of entering any code to some part of a webpage. I have some problems with it. When i put some code in the script then their is no error shown. When i try to not use a code and leave it empty the following php errors happens. I dont understand why. Help me.
Error shown are: -
PHP Notice: in file /index.php on line 132: Undefined offset: 4
PHP Notice: in file /index.php on line 141:...
|
by: neridaj |
last post by:
Hello,
I'm trying to figure out how to get rid of these errors:
Notice: Undefined offset: 1 in output_fns.php on line 315
Notice: getimagesize() : Read error! in
output_fns.php on line 315
function get_imgdim()
|
by: raydiamond4u |
last post by:
Hello. My name is Raymond.
My code is generating the following error: Notice: Undefined offset: 2 in C:\wamp\www\imagegallery\supportfile\include\config.php on line 25
How do i correct the error?
Here is the code:
<?php
// Include file for database connectivity
$db_server = "localhost";
|
by: razvanel442 |
last post by:
Hi all i am new here!
I take a look on forum but i don't found a the answer for my problem
ok this is my problem:
Line47:$user = $_GET;
Line48:$pass = $_GET;
Line49:$char = $_GET;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |