CodeCanyon

how can I do this???

9 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
zaheen says

I have the following function, but as I am not a pro programmer, I don’t know how to achieve my goal. here is the code and I will explain what I wanted below.

$menu = $db->GetAll($sql); foreach ($menu as $row) { $label = '<a href="'.$row[MENU_URL].'">'; $label .= $row[MENU_TITLE]; $label .= '</a>';

What I wanted to do is id $label .= $row[MENU_TITLE]; contains http://, then open that link in a new tab. I am sure there many great progrmammers who can achieve this with few ways, I am sure Jeff will do it in seconds…. as many others can do it.

Please someone help me to solve this problem

Thank you

Zaheen

2844 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 1000 and 1999 users
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+4 more
sevenspark moderator says

Hi Zaheen,

You can use the strpos function to check for the http within the string and then conditionally add the target=”_blank” attribute to your anchor :)

9 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 2-3 years
zaheen says
Thank you very much for the reply… and I am glad to say Sean helped me with if( substr($row[MENU_URL], 0, 4) == "http") { to solve the problem and now its ok

Anyways this is so great forum to get help.

Thank you again

Zaheen

by
by
by
by
by