Question

I need to run a php condition to check for the text that's clicked in a tab. I need to check the text value instead of the url as the url is the same, only text is different. Here's what I have so far:

<a href="/some-value">Tab 1</a> 
<a href="/some-value">Tab 2</a> 

<?php 
    $a = 'Tab 1'; //How to check for this value?
    $b = 'Tab 2';

    if (strpos($a,'Tab 1') !== false) {
        echo 'Tab 1'; 
    } else { 
        echo 'Tab 2'; 
    } 
?>
Was it helpful?

Solution

i think it will be better to set the text of anchor in the url.

Like this:

<a href="/some-value?tab=Tab 1">Tab 1</a> 
<a href="/some-value?tab=Tab 2">Tab 2</a> 

And then if you want to know which tab clicked just get the tab value

$_REQUEST['tab']
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top