0

The following array when printed shows that the value of $career[2] is 2010-.

However no matter what I try, this if equation will not trigger. Can these array variables be different in some way?

echo $career[2];

    if($career[2] == "2010-"){
        $career = $career[1];
    } 

A print_r of the array $career reveals this..

 Array ( 
[0] => BIS career 
[1] => CEO of the corp 
[2] => 2010- 
[3] => Leader of R&D 
[4] => 2005-10 
);

VAR DUMP

    array(11) { 
[0]=> string(316) "BIS career " 
[1]=> string(194) " CEO of the corp " 
[2]=> string(163) " 2010- " 
[3]=> string(160) " Leader of R&D " 
[4]=> string(165) " 2005-10 " }
Walrus
  • 19,801
  • 35
  • 121
  • 199

1 Answers1

1

You can also do:

echo "...".$career[2]."...";

it will reflect the space

Try:

preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$str);

reference: Trim unicode whitespace in PHP 5.2

Community
  • 1
  • 1
  • Var Dump is giving me this... string(31) " 2010- " Trim does not seam to fix it. – Walrus May 15 '15 at 14:56
  • 1
    as taken from: http://stackoverflow.com/questions/4166896/trim-unicode-whitespace-in-php-5-2, try: preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$str); – Arunabh Trivedi May 15 '15 at 15:03
  • Robin its hard to do with looking into the actual string, can you try http://sandbox.onlinephpfunctions.com/ and share it, also try: strpos to search for "2010-", to see what you get in return, http://php.net/manual/en/function.strrpos.php – Arunabh Trivedi May 15 '15 at 15:14
  • I've found it. Although the string did not show any html when doing strpos I found it still contained tags. I have removed them with strip tags function. Baffling – Walrus May 15 '15 at 15:16