if logic that figures into it  a minumum string length

Posted on 2008-11-10
Last Modified: 2012-05-05

the attached code works great -

<li " . ($value['link']=="faqs" ? "style=\"padding:0 2px 0 2px;\"": "").">

says that if the parameter is "faqs" add padding to the <li>

i'm wondering if there's a way to do this but instead of ($value['link']=="faqs"  being the parameter, some sort of miniumum string length serving as the parameter instead like:

<li " . (stringlenth<4 characters ? "style=\"padding:0 2px 0 2px;\"": "").">

function showMenu ( $menu_array, $toplevel, $page, $subpage ) {

                global $d, $ak;


                //Display the top level elements.

                echo "<ul>\n";

                foreach($menu_array as $key => $value):

                        if ($toplevel):

                                $url = "index.php?page=" . $value['link'];

                                $active = ($page == $value['link']) ? "class=\"active\"" : "";


                                $url = "index.php?page=$page&amp;subpage=" . $value['link'];

                                $active = ($subpage == $value['link']) ? "class=\"active\"" : "";


                        $target = menus::getTarget($value['target'], $url);


                        //If user is logged in, change login page link to read logout

                        if (count($_SESSION['clientuser']) && strcmp(strtolower($value['link']), 'sign_in') == 0)

                                $value['title'] = 'Logout';


                        //Do not show item if it is restricted in access and user is not logged in.

                        if ($value['restricted'] && !count($_SESSION['clientuser'])):


                                echo "\t<li " . ($value['link']=="faqs" ? "style=\"padding:0 2px 0 2px;\"": "")."><a href=\"" . menus::checksef($url) . "\" $target $active tabindex=\"" . $ak->tabindex($key) . "\">". $value['title'] ."</a></li>\n";



                echo "</ul>\n";


Open in new window

Question by:phillystyle123
    LVL 82

    Accepted Solution

    <li " . ( (strlen($value['link']) < 4) ? "style=\"padding:0 2px 0 2px;\"": "").">

    Open in new window


    Author Closing Comment

    thanks hielo! - sorry for the delay

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now