Jump to content

Search the Community

Showing results for tags 'multi-dimensional'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I have a multi-dimensional array (something as below). What am trying to do is find a specific value, and if that value has children, list only those children. So for example, if am searching for slug's "test", then all of "test's" children list on the page. "Test2" has no children, so none listed. If am searching for "/test/sub" (the slug), and since it has children, I wanted to show all of the children (eg. "sh", "rd", "co"). I have only a code for checking a multi-dimensional array, but am lost as to how to go beyond that. function in_array_r($needle, $haystack, $strict = true) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; } } return false; } Array ( [test] => Array ( [children] => Array ( [2] => Array ( [parent] => 4 [title] => Sub [slug] => test/sub/ [id] => 2 [children] => Array ( [3] => Array ( [parent] => 2 [title] => sh [slug] => test/sub/sh [id] => 3 ) [27] => Array ( [parent] => 2 [title] => RD [slug] => test/sub/rd [id] => 27 ) [145] => Array ( [parent] => 2 [title] => cO [slug] => test/sub/co [id] => 145 ) ) ) [8] => Array ( [parent] => 4 [title] => sub2 [slug] => test/sub2 [id] => 8 ) [19] => Array ( [parent] => 4 [title] => sub3 [slug] => test/sub3 [id] => 19 [children] => Array ( [20] => Array ( [parent] => 19 [title] => child1 [slug] => test/sub3/child1 [id] => 20 ) [21] => Array ( [parent] => 19 [title] => child2 [slug] => test/sub3/child2 [id] => 21 ) ) )
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.