NUmber of indentations in array?
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
NUmber of indentations in array?
Is there a function, or could I easily make a function, that figures out how deep a value is in an array? For example, $my_array['this']['that']['these']['those'] would produce a result of four, $my_other_array['hmm']['huh']['what'] would produce a result of three, etc.
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
-
- New member
- Posts: 7
- Joined: 13 Jun 2007, 22:02
- Real name: Tyler King
- Location: Newfoundland, Canada
- Contact:
Re: NUmber of indentations in array?
- An all-in-one clan, ladder and tournament script.
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: NUmber of indentations in array?
Thanks AI Bot, will test now.
EDIT: Works like a charm. Thank you very much.
EDIT: Works like a charm. Thank you very much.
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: NUmber of indentations in array?
Per the phpBB3 coding guidelines you could use sizeof instead of count. No real difference but perhaps worth a mention.
- we're poor!
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: NUmber of indentations in array?
sizeof would be how many things...
eg
array(1 => 't, 2 => 'r')
would return 2. However, this is the depth, not the number of values.
eg
array(1 => 't, 2 => 'r')
would return 2. However, this is the depth, not the number of values.
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: NUmber of indentations in array?
sizeof is an alias of count. So maybe this is not what you're looking for.
- we're poor!
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: NUmber of indentations in array?
No, I tested it and it works...I think its , COUNT_RECURSIVE that makes it work...so if Sizeof is an alias, I can do sizeof($my_array, COUNT_RECURSIVE) and it would be the same as count($my_array, COUNT_RECURSIVE)???
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: NUmber of indentations in array?
- we're poor!
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: NUmber of indentations in array?
Oh...so that's not what I want
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
- igorw
- Past Contributor
- Posts: 1967
- Joined: 01 Jun 2006, 20:48
- Real name: Igor [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: NUmber of indentations in array?
Last edited by igorw on 12 Jan 2015, 23:59, edited 2 times in total.
Reason: changed a bit
Reason: changed a bit
- we're poor!
-
- Supporter
- Posts: 316
- Joined: 18 Sep 2007, 14:35
- Real name: David
- Contact:
Re: NUmber of indentations in array?
Thank you. I will check if it works in a moment
That's like, I can't beat my neighbor in an argument, so instead I kill his dog.
-Best English Teacher Ever
Return to “phpBB Development discussion”
Who is online
Users browsing this forum: No registered users and 12 guests