How to

<?php
if ($kebab contains A letter to a-z){ ?>
<a href=“bksalDLALSA.html” >ppppp</a>
<?php}?>

what do i type instede for contains A letter to a-z in php?

‘contains A letter to a-z’? Slight language barrier i think.
You mean that the variable has inside it something that contains a lowercase letter at any point? or contains only lowercase letters? or is exactly 1 lowercase letter? or?

food1234 or fordfalcon but if it only contains numbers the if code shouldn’t work!!!

okay so ‘if it contains at least one lowercase letter’.

if(preg_match(“/[a-z]/”,$kebab)) {

Let’s turn that around to: don’t do anything if the variable contains only digits.


if (!ctype_digit($kebab)) {

}

Edit:

StarLion beat me to it :slight_smile:

Using a regular expression would be how I’d do it.


<?php
preg_match("[^a-zA-Z]", $kebab, $matches, PREG_OFFSET_CAPTURE, 3);
if ($matches == 0) { ?>
<a href="bksalDLALSA.html">ppppp</a>
<?php
} ?>

Edit:

Dangit - beaten again…grrr.

(but mine checks for all alphas, upper and lower) :smiley:

Off Topic:

Did someone say Kebab? Mmm

mmmh… be careful there, Scallio - containing an alpha is not the same as not being all digits. (1231.21 is not all digits because of the ., but still doesnt meet the criteria)