On Wed, 2006-05-03 at 13:27, Dave Goodchild wrote:
use:
$new_array = array_chunk($input_array, 3));
this will split your original array into a number of arrays with three
elements in each and trash the original keys. If you want to preserve the
keys pass a third paramater (true). Hope
Dave Goodchild wrote:
use:
$new_array = array_chunk($input_array, 3));
Thanks, that is just the array function I was looking for.
this will split your original array into a number of arrays with three
elements in each and trash the original keys. If you want to preserve the
keys pass a
On Wed, 2006-05-03 at 13:42, Jason Gerfen wrote:
Dave Goodchild wrote:
use:
$new_array = array_chunk($input_array, 3));
Thanks, that is just the array function I was looking for.
Really? Wow! That'll produce nothing like the example you said you
wanted. *lol*
Cheers,
Rob.
--
On Sat, 2006-04-22 at 15:31, Martin Alterisio wrote:
You're wrong, he isn't using an associative array, since the keys used
are only integers.
Well, if you really want to argue semantics then technically we're both
wrong because there are no different indexed and associative array types
in PHP,
On Sat, 2006-04-22 at 14:16, Jochem Maas wrote:
with regard to Suresh - do you, Brian, know how many times he has posted
similar
question to this list this year? (this is the first time he has even given
an indication that he knows where the manual is let alone opened it btw) do
you
know
Tiresome.
On 23/04/06, Brian V Bonini [EMAIL PROTECTED] wrote:
On Sat, 2006-04-22 at 14:16, Jochem Maas wrote:
with regard to Suresh - do you, Brian, know how many times he has posted
similar
question to this list this year? (this is the first time he has even
given
an indication that
sorry.earlier i mistyped some values.
I am facing one project in my project .
this is my code:
a=array(0=10,1=10,2=40,3=30,4=30,5=10);
b=array();
b=array_unique($a);
print_r($b);
o/p getting from above code is b[0]=10,b[2]=40,b[3]=30,b[5]=10;
but i want the
On Sat, 2006-04-22 at 07:09, suresh kumar wrote:
sorry.earlier i mistyped some values.
I am facing one project in my project .
this is my code:
a=array(0=10,1=10,2=40,3=30,4=30,5=10);
b=array();
b=array_unique($a);
print_r($b);
o/p getting from above code
suresh kumar wrote:
sorry.earlier i mistyped some values.
I am facing one project in my project .
this is my code:
a=array(0=10,1=10,2=40,3=30,4=30,5=10);
b=array();
b=array_unique($a);
print_r($b);
o/p getting from above code is b[0]=10,b[2]=40,b[3]=30,b[5]=10;
Jochem's site:
snip
http://iamjochem.com/mariecke/index.php
Mariecke's daily ramblings (almost) in dutch english... this page is
using output from a drupal system.
If nothing else they have a nice logo. ;)
Warning: main(./../blog/parse.php): failed to open stream: No such file
or directory
thanks Brian.
that site has not worked for, oh, 3 years - I don't see what some broken
code on some site I haven't done anything with in years has got to do
with programmer ethic (or whatever advice you were refering to).
- am I bugging you for a fix?
with regard to Suresh - do you, Brian, know
You're wrong, he isn't using an associative array, since the keys used are
only integers.
array(10,10,40,30,30,10);
and
array(0=10,1=10,2=40,3=30,4=30,5=10);
create the same array.
The problem is that array_unique preserves keys (read the manual!!!)
If you don't want this, use array_values() to
So, I have an array that looks like this
rray(3) {
[0]=
array(8) {
[line]=
string(1) 1
[ponbr]=
string(5) 34474
[emt]=
string(3) yes
[qty]=
string(1) 5
[price]=
string(2) 19
[shipdate]=
string(8) 11/06/07
[tracking]=
string(17)
Let me try this again. I want to take an array that may look like this
array(2) {
[0]=
array(8) {
[line]=
string(1) 1
[ponbr]=
string(5) TEST1
[emt]=
string(3) yes
[qty]=
string(1) 5
[price]=
string(2) 19
[shipdate]=
string(8) 12/04/06
Hi,
How can I sort a 2 dimensional array by number of
elements?
Ex:
rgArray[0] = ("1","2");
rgArray[1] = ("1");
rgArray[2] = ("1","2","3","4");
rgArray[3] = ("1","2","3");
Now I would like to sort it so I can loop through
them from least elements to most (or vice versa):
rgArray[1] (now
[snip]
How can I sort a 2 dimensional array by number of elements?
[/snip]
Start by RTFM http://www.php.net/manual/en/function.count.php
[EMAIL PROTECTED] wrote:
[snip]
How can I sort a 2 dimensional array by number of elements?
[/snip]
Start by RTFM http://www.php.net/manual/en/function.count.php
I love how infinitely helpful people on this mailing list are. It's a
wonder people are being turned off to PHP. There's
[snip]
I love how infinitely helpful people on this mailing list are. It's a
wonder people are being turned off to PHP. There's no one here willing
to help new people more than throwing them RTFM responses.
[/snip]
Are you new here? I would rather teach a man how to fish than give him
his supper
Sometimes I just need a point in the right direction. So RTFM is not
so bad.
Erik
On Feb 28, 2006, at 11:26 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
[snip]
I love how infinitely helpful people on this mailing list are. It's a
wonder people are being turned off to PHP. There's no
[EMAIL PROTECTED] wrote:
[snip]
I love how infinitely helpful people on this mailing list are. It's a
wonder people are being turned off to PHP. There's no one here willing
to help new people more than throwing them RTFM responses.
[/snip]
Are you new here? I would rather teach a man how to
Saline Erik wrote:
Sometimes I just need a point in the right direction. So RTFM is not
so bad.
Erik
If you say so. In that case, jblanchard, I apologize for my outburst.
--
Jeremy Privett
Director of Product Development
Zend Certified Engineer
Completely Unique
[EMAIL PROTECTED]
Phone:
Jeremy Privett wrote:
[EMAIL PROTECTED] wrote:
[snip]
How can I sort a 2 dimensional array by number of elements?
[/snip]
Start by RTFM http://www.php.net/manual/en/function.count.php
I love how infinitely helpful people on this mailing list are. It's a
wonder people are being
[snip]
If you say so. In that case, jblanchard, I apologize for my outburst.
[/snip]
Apology accepted. Look, several of us have been on this list for years
and have helped several others through their issues. Mailing lists like
this (try a C++ newsgroup for example) are much more merciless than
On 28/02/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
The array sorting suggestions you provide will not sort based on the
number of items in each array, which is what the OP wanted.
That's not entirely fair. I would have said his usort() suggestion was
a better pointer than a link to count()
[snip]
That's not entirely fair. I would have said his usort() suggestion was
a better pointer than a link to count() - which gives no hint as to
how to sort the list, which is after all what the OP's trying to do.
ObSuggestion:
function byLength($a, $b)
{
return sizeof($a) - sizeof($b);
}
snip
I would rather teach a man how to fish than give him
his supper on a silver platter.
/snip
Write his code and you can reduce his frustration for a day, but
teach him to program and you'll frustrate him for life.
tedd
--
Just came across some code I haven't seen before and can't find anything on
php.net or google about it (maybe I'm not searching for the right thing?).
What is the following doing?
// $dataobject is holding a bunch of variables like:
// $dataobject-var1
// $dataobject-var2
// etc...
Jay Paulson wrote:
Just came across some code I haven't seen before and can't find anything on
php.net or google about it (maybe I'm not searching for the right thing?).
What is the following doing?
// $dataobject is holding a bunch of variables like:
// $dataobject-var1
//
On Wednesday 22 February 2006 15:09, John Nichel wrote:
Jay Paulson wrote:
Just came across some code I haven't seen before and can't find anything
on php.net or google about it (maybe I'm not searching for the right
thing?). What is the following doing?
// $dataobject is holding a
I recently encountered a situation where I had to retrieve data from a MYSQL
database table with a field named include. My code looked like this:
$content_result = mysql_query('SELECT * FROM calander') or
die(mysql_error());
$content_row = mysql_fetch_array($content_result);
if
When I tried to run this, PHP treated the word -include- as a control
structure rather than an index name. Understandable. So, I put it in single
quotes ('include') to see what would happen and it works fine. But I don't
understand why!
What is the difference between $content_row [include]
Maybe I'm just blind, but I can't find any way to count an array size in
bytes? I have a quite big array with multiple data formats in it, and I
would like to know how big it is in bytes...
--
Anders Norrbring
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
Maybe I'm just blind, but I can't find any way to count an array
size in bytes? I have a quite big array with multiple data formats
in it, and I would like to know how big it is in bytes...
--
Anders Norrbring
Yeah, I know -- sizeof is simply count, which doesn't solve the problem.
You
Hallo,
I have a form with a number of checkboxes grouped together. The value of
these boxes is stored in an array: $used[]. Now I found that the value of
checked boxes (value = 'Y') are stored in the array while non checked boxes
are not stored at all. This makes the array incomplete as I want to
Hallo,
I have a form with a number of checkboxes grouped together.
The value of
these boxes is stored in an array: $used[]. Now I found that
the value of
checked boxes (value = 'Y') are stored in the array while non
checked boxes
are not stored at all. This makes the array incomplete as
Cyril wrote:
Is there any way of converting an array to an object of a type/class
other than stdClass?
write a function? - bare in mind this is just an idea -
it would need more work to make it usuable (and the code
is completely untested):
class Test {}
function castFromArray($class, $arr)
{
Is there any way of converting an array to an object of a type/class
other than stdClass?
I have been using the new PDO system and have experimented with
fetching rows with PDO::FETCH_CLASS
I would quite like to do the same with a plain array.
Any comments appreciated.
Cyril
--
PHP General
I have an array $journal that I want to carry from a page (where it was
created) to another page (a popup that shows the variables contents). Is
this automatically available? or do I have to do something special to php??
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
??
It can be sort of automatically:
?php
$array = array('my', 'list', 'of', 'stuff');
$_SESSION['array_for_popup'] = $array;
?
And in the code that is called in the popup:
?php
if(!isset($_SESSION['array_for_popup']) {
die('you should not be here anyway, only on a popup is this allowed
Session variable or hidden field maybe
Eternity Records Webmaster wrote:
I have an array $journal that I want to carry from a page (where it was
created) to another page (a popup that shows the variables contents). Is
this automatically available? or do I have to do something special to php??
you could just pass in in the address, eg:
www.example.com?var1=$var1var2=$var2
to get them use $_REQUEST['var1']
to pass an array you could use serialize($var1) and unserialize($var1)
On 12/8/05, Chris Shiflett [EMAIL PROTECTED] wrote:
Curt Zirzow wrote:
?php
$array = array('my', 'list
Curt Zirzow wrote:
?php
$array = array('my', 'list', 'of', 'stuff');
$_SESSION['array_for_popup'] = $array;
?
And in the code that is called in the popup:
?php
if(!isset($_SESSION['array_for_popup']) {
die('you should not be here anyway, only on a popup is this allowed');
}
$array
On Thu, Dec 08, 2005 at 02:39:46AM -0500, Zack Bloom wrote:
you could just pass in in the address, eg:
www.example.com?var1=$var1var2=$var2
to get them use $_REQUEST['var1']
to pass an array you could use serialize($var1) and unserialize($var1)
Or just use http_build_query() (php5 only)
Hello all,
I have some array code driving me nuts.
I am pulling from a db:
select id, vehicle, has_quotes from cars where active=1
I then loop through these and build an array that contains the id's and cars.
while($res){
$cars[$res[id]]=$res[vehicle];
//here is the problem, when has_quotes
Got it figured out by now. I noticed one small bug but I'll fix it monday
morning, so i'm going to post what I did to make this work..
I'm going to donate this code to the guy at
http://www.devdump.com/phpxml.php and hopefully he'll put some of this to a
good use as more and more people are now
Scott, I hope this code help you:
[PHP CODE]
/*
* Author:
* Josue Aranda [EMAIL PROTECTED]
*/
// This set an $arr
$arr= array(
'ABC' = array(
'DEF' = 'Data'
Greetings PHP community,
I have a CSV text file which I need to use to update existing DB
records.
So I have the following :
$array_file = file(path/to/file);
file() creates an array comprising each line of the file, but if each
line contains 20 or so CS values, how do I go about reading each
?php
$array_file = file(path/to/file);
foreach($array_file as $line)
{
$e_array = explode(',',$line);
{
// do update on db for each line of array
}
}
?
Like this?
Emil Novak, Slovenia, EU
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe,
On Fri, 2005-09-30 at 15:33, Emil Novak wrote:
?php
$array_file = file(path/to/file);
foreach($array_file as $line)
{
$e_array = explode(',',$line);
{
// do update on db for each line of array
}
}
?
Like this?
Hi Emil,
That`s exactly how I figured it
Suppose that I'm in a child array and I wanna know how do I tell what key is
the parent's level, one level up...
For example,
--snip--
$arr['ABC']['DEF'];
--snip--
Let's say the child is DEF then the key name one level up would be ABC.
How do I determine the one level up?
Thanks...
--
PHP
On 9/28/05, Silvio Porcellana [EMAIL PROTECTED] wrote:
In addiction, I would (SQL)escape the values joined: supposing you are
using MySQL, I'd do:
$values = join(', ', array_map('mysql_real_escape_string', $array));
I agree entirely; I was just trying to keep things simple for the OP.
the xml above is not structurally
the same as the array below
I'll bet your output has just one message
element right? or you have gone completely offtrack.
might be time you went here:
http://php.net/xml
http://php.net/dom
http://php.net/domxml
might be something there to help
I'm using the recursive function and it use the foreach() loop. I can
figure out how to use the current key but I could not figure out how to use
the parent's key. Can anyone point out to what I'm missing here?
Just look at the //Parent Key - How?? comment in the script...I'm not
sure what
Hi All,
Hope you can help me out..
Array ( [count] = 1 [0] = Array ( [clientaccountmanager] = Array (
[count] = 2 [0] = 210 [1] = 149 )
I've got the following Query=select * from client WHERE
clientaccountmanager='$value of array1' OR '$2nd value of array 1'
So that the query loops through the
[snip]
Hope you can help me out..
Array ( [count] = 1 [0] = Array ( [clientaccountmanager] = Array (
[count] = 2 [0] = 210 [1] = 149 )
I've got the following Query=select * from client WHERE
clientaccountmanager='$value of array1' OR '$2nd value of array 1'
So that the query loops through the
O.K. Again;
I have an array with one or more values, which must be selected in the
database
Array ( [count] = 1 [0] = Array ( [clientaccountmanager] = Array (
[count] = 2 [0] = 210 [1] = 149 )
Now i this is my select..
I've got the following Query=select * from client WHERE
On 9/28/05, Frank Keessen [EMAIL PROTECTED] wrote:
O.K. Again;
I have an array with one or more values, which must be selected in the
database
Array ( [count] = 1 [0] = Array ( [clientaccountmanager] = Array (
[count] = 2 [0] = 210 [1] = 149 )
Now i this is my select..
I've got the
There is a small bug in your code:
[snip]
$values = join(', ', $array);
$query = SELECT * FROM client WHERE clientaccountmanager IN ($values)
[/snip]
You'll need to surround $values with a single quote after joining:
[code]
$values = join(', ', $array);
$query = SELECT * FROM client WHERE
To the top...
Aw!!! This is driving me nut... I can't get it to do what I want it to
do... Also, another problem is that we're all not thinking at the same
level so I'll just dump the simple code so you all can see what I'm trying
to do...
[code]
function getVal($arr, $path)
{
A.J. Brown wrote:
[code]
$values = join(', ', $array);
$query = SELECT * FROM client WHERE clientaccountmanager IN ('$values')
[/code]
Actually this doesn't seem right, the join should be:
$values = join(', ', $array); # notice the ' inside the
In addiction, I would (SQL)escape the
Silvio Porcellana mailto:[EMAIL PROTECTED]
on Wednesday, September 28, 2005 9:37 AM said:
In addiction, I would (SQL)escape the values joined: supposing you are
using MySQL, I'd do:
$values = join(', ', array_map('mysql_real_escape_string', $array));
Now that's a Freudian slip if I ever
Scott Fletcher wrote:
To the top...
Aw!!! This is driving me nut... I can't get it to do what I want it to
do... Also, another problem is that we're all not thinking at the same
level so I'll just dump the simple code so you all can see what I'm trying
to do...
[code]
fantastic function -
Aw!!! This is driving me nut...
It still does :-)
get to grips with var_dump() ...
Um Interesting thought...
($array.$suffix) will never be an array
$suffix .= ['.$key.'];
Yea, you are correct... I was trying to integrate the coding and stumpled
upon this. It's a
Scott Fletcher wrote:
Aw!!! This is driving me nut...
It still does :-)
get to grips with var_dump() ...
Um Interesting thought...
($array.$suffix) will never be an array
$suffix .= ['.$key.'];
Yea, you are correct... I was trying to integrate the coding and stumpled
Here is something simple that I want it to work.. Not sure how to do this
exactly...
Code #1
[code]
$array = array();
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
echo $array['col3']['col2']; //Spitted out result as Test #2...
[/code]
What I want this to work
Scott Fletcher wrote:
What I want this to work instead is
[code]
$array = array();
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
$prefix = ['col3']['col2'];
echo $array.$prefix; //Spitted out result as Test #2...
[/code]
Try something like this:
code
$var
On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
[code]
$array = array();
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
$prefix = ['col3']['col2'];
echo $array.$prefix; //Spitted out result as Test #2...
[/code]
This is the simple code that I'm trying to
Mike Dunlop wrote:
On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
[code]
$array = array();
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
$prefix = ['col3']['col2'];
echo $array.$prefix; //Spitted out result as Test #2...
[/code]
This is the simple code
Wow, that seem to work... Should have use $suffix instead of $prefix to
make it less confusing.
Silvio Porcellana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Scott Fletcher wrote:
What I want this to work instead is
[code]
$array = array();
$array['col1']['col2'] = Test
Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Mike Dunlop wrote:
On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
[code]
$array = array();
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
$prefix = ['col3']['col2'];
see below..
Scott Fletcher wrote:
Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Mike Dunlop wrote:
On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
[code]
$array = array();
$array['col1']['col2'] = Test #1;
$array['col3']['col2'] = Test #2;
$prefix =
My bad - that doesn't work - that came off the top off my head. It
sure did look sexy though, no ?
- MD
echo ${array.$prefix};
really? did you test that?
doesn't work when I do it (the second expression does
- but doesn't answer the OPs question actually imho the
answer is not eval()
:-)
Mike Dunlop [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
My bad - that doesn't work - that came off the top off my head. It
sure did look sexy though, no ?
- MD
echo ${array.$prefix};
really? did you test that?
doesn't work when I do it (the second expression
see below...
Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
see below..
Scott Fletcher wrote:
Jochem Maas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Mike Dunlop wrote:
On Sep 27, 2005, at 10:22 AM, Scott Fletcher wrote:
[code]
$array =
hello,
I have a simple question, not really a problem this time.
I know that the function print_r() will print an array but if that array
has sub-arrays it prints everything and if you don't use more command or a
pipe of some kind that could be useless in some cases, but I am just
wondering,
tray print the array this way:
echo 'pre';
print_r($array);
echo '/pre';
-afan
matt VanDeWalle wrote:
hello,
I have a simple question, not really a problem this time.
I know that the function print_r() will print an array but if that
array has sub-arrays it prints everything and if you
please provide code and an example output, and say how this is
different than you would like. what you describe is unclear.
Jordan
On Sep 13, 2005, at 4:04 PM, matt VanDeWalle wrote:
hello,
I have a simple question, not really a problem this time.
I know that the function print_r() will
it to not preserve keys.
?php
$array = array( 'this', 'is', 'my', array( 'array' ) );
$newArray = array();
foreach( $array as $key=$value ) {
if( !is_array( $value ) ) {
$newArray[$key] = $value;
}
}
print( 'pre' . print_r( $newArray, true ) . '/pre' );
?
--
Jasper Bryant
If you want to print the keys for all the arrays in the main array then
use allkeys.
matt VanDeWalle wrote:
hello,
I have a simple question, not really a problem this time.
I know that the function print_r() will print an array but if that
array has sub-arrays it prints everything and if
hey, thanks for jogging my memory about the array_keys ; that was exactly
what i wanted,
now I don't have to run the program through the more program now, and i
got all the names of the arrays in the big array without having half of
the info scrolling off the screen.
thanks
matt
--
PHP
Hello,
I have just rewrite the source and test the result...
But it is still problem !
So, more help ?
Thanks !
[EMAIL PROTECTED] wrote:
Hello Jasper,
Does your means :
I need to rewite the source / result page as the following ?
Result page:
?
for($i=0;$i4;$i++)
{
i have the array with the following structure :
Array
(
[19] = 20.00
[25] = 20.00
[7] = 30.00
[17] = 30.00
)
when i merge a field to it using array_merge
it returns that :
Array
(
[0] = 20.00
[1] = 20.00
[2] = 30.00
[3] = 30.00
[4] = 200.00
)
how can i merge
] = data
)
/manual snippets
Its actually on the same page as array_merge in array functions.
-Original Message-
From: Ahmed Abdel-Aliem [mailto:[EMAIL PROTECTED]
Sent: 01 September 2005 09:43
To: php-general@lists.php.net
Subject: [PHP] array merge problem
Sorry, I don't quit understanding the site http://www.php.net/for...
So, would you mind to give me a example about it ?
Thank for your help !
Jasper Bryant-Greene wrote:
Dan Lowe wrote:
for($i=1;$i5;$i++)
This means:
* Start with $i = 1
* End loop if $i is less than 5
* Increment
[EMAIL PROTECTED] wrote:
Sorry, I don't quit understanding the site http://www.php.net/for...
So, would you mind to give me a example about it ?
for($i=0; $i3; $i++) {
print($i);
}
will print:
0
1
2
Basically in any expression like the following:
for(expr1; expr2; expr3) {
Hello Jasper,
Does your means :
I need to rewite the source / result page as the following ?
Result page:
?
for($i=0;$i4;$i++)
{
$f.$i=$_GET['$f.$i'];
}
?
table
tr
td? echo $f0[0];?/td
td? echo $f1[0];?/td
td? echo $f2[0];?/td
td? echo $f3[0];?/td
/tr
tr
td? echo $f0[1];?/td
td? echo
[EMAIL PROTECTED] wrote:
Hello Jasper,
Does your means :
I need to rewite the source / result page as the following ?
[snip]
Yes.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Dear you,
Now, I want to define a set of array varible with table structure as the
following:
Result page:
table
tr
td? $f1[0];?/td
td? $f2[0];?/td
td? $f3[0];?/td
td? $f4[0];?/td
/tr
tr
td? $f1[1];?/td
td? $f2[1];?/td
td? $f3[1];?/td
td? $f4[1];?/td
/tr
tr
td? $f1[2];?/td
td? $f2[2];?/td
td?
On Aug 13, 2005, at 8:35 AM, [EMAIL PROTECTED] wrote:
table
tr
for($i=1;$i5;$i++)
This means:
* Start with $i = 1
* End loop if $i is less than 5
* Increment $i each time around
So your loop is ending at the first check because $i is less than 5.
You want $i 4 instead, I think.
-dan
Dan Lowe wrote:
for($i=1;$i5;$i++)
This means:
* Start with $i = 1
* End loop if $i is less than 5
* Increment $i each time around
So your loop is ending at the first check because $i is less than 5.
You want $i 4 instead, I think.
Umm, no, I don't think so... Your second point is
Edward Vermillion wrote:
Sebastian wrote:
is it always necessary to call array() when you do something like this:
mysql_query(SELECT );
while($rows .)
{
$data[] = $rows;
}
if so, why? i have a habit of never calling array() and someone told
me i shouldn't do this.
If that's
You're using a lot of negatives.
$data = array(); // You should initialise $data to array() for various reasons:
// 1: self_documentation - to anyone who reads your code will be obvious
// that $data should contain an empty array
// 2: security - if someone goes to
//
Rory Browne wrote:
You're using a lot of negatives.
nice catch on the double neg Rory :-)
$data = array(); // You should initialise $data to array() for various reasons:
// 1: self_documentation - to anyone who reads your code will be obvious
// that $data should contain an empty
is it always necessary to call array() when you do something like this:
mysql_query(SELECT );
while($rows .)
{
$data[] = $rows;
}
if so, why? i have a habit of never calling array() and someone told me
i shouldn't do this.
--
No virus found in this outgoing message.
Checked by
Sebastian wrote:
is it always necessary to call array() when you do something like this:
mysql_query(SELECT );
while($rows .)
{
$data[] = $rows;
}
if so, why? i have a habit of never calling array() and someone told me
i shouldn't do this.
If that's your first use of $data then
Hi .
Please could you advise.
I'm insearch of a java fold out menu that looks good, and can acept an
array containg the links and link names etc from a php array ... i
havent worked in java script yet so please help :-)...
Many thanks
--
Gregory Machin
[EMAIL PROTECTED]
[EMAIL PROTECTED
How does one represent a MySQL table as a two dimensional array
using the column names as one of the indices? My naive attempt
went something like this:
while ($row = mysqli_fetch_assoc($result))
$table[] = $row;
but that generated this error;
Fatal error: []
Did you bother to initialize $table as an array() or are you another
lazy slob of a programmer that expects the engine to read your mind
(cluttered as that may be)?
Cheers,
Rob.
On Thu, 2005-07-14 at 18:33, Fletcher Mattox wrote:
How does one represent a MySQL table as a two dimensional array
Hello Fletcher,
Thursday, July 14, 2005, 11:33:36 PM, you wrote:
FM while ($row = mysqli_fetch_assoc($result))
FM $table[] = $row;
FM but that generated this error;
FM Fatal error: [] operator not supported for strings
The above WILL work providing that (1)
Rob writes:
Did you bother to initialize $table as an array() or are you another
lazy slob of a programmer that expects the engine to read your mind
(cluttered as that may be)?
Bingo.
You seem to have no trouble reading my mind, why can't php? :)
Years of perl programming has promoted a
401 - 500 of 1246 matches
Mail list logo