Jump to content

preg_match() question


robert_gsfame

Recommended Posts

not shure wut u mean. but here is a function, checks for female/male

 

<?php

$val="male";

$gender=preg_match('/\b(?:fe)?male/',$val,$match)?(substr($match[0],0,1)=='m'?1:2):FALSE;

echo $gender .PHP_EOL;

echo ($gender==1?'Male':($gender==2?'Female':'Other')) . PHP_EOL;

?>

 

Link to comment
https://forums.phpfreaks.com/topic/221485-preg_match-question/#findComment-1146536
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.