troubleshooting Question

PHP an removing whitespaces

Avatar of dogsareit
dogsareitFlag for United States of America asked on
PHP
4 Comments1 Solution55 ViewsLast Modified:
I am extracting data from a pdf and so far, it's has been going fairly decent. I am working in localhost, Win 10, WampServer and using PHP 5.6.25.
I am using PdfParser and used composer to install it. It was successful. I am trying to explode a line of data on whitespace and it simple will not do it. I have done this before without a problem. I know from experience, that what I view in I.E. - source view - may not be what it really is to me visually. They appear to be a whitespace(s), so I decided that I would count the number of whitespaces in order to create the correct length for exploding on properly, and it returns a count of zero. I have tried to replace the whitespace(s) with another character - * - and it will not do it. I have even tried using chr(32) to represent the whitespace(s).
Therefore, even though it "looks" like a whitespace, maybe it really isn't. But I have no clue as to what it is or how to resolve it.
Can someone guide/educate me about what to try next or how to resolve this ??
I have other lines of data that I will need to explode based on whitespaces in this project.
Below is the snippet of coding: I have also attached a snapshot of what it looks in the source pane of I.E.
	if ($strtype == 'account')
        	{
			// look for actnbr
                       $wrkBegChar = 'AccountNumber';
	               $wrkEndChar = 'USD';
	     	       $strBegPos = stripos($strSearchData , $wrkBegChar,1); 
	    	       $strEndPos = stripos($strSearchData, $wrkEndChar, $strBegPos); 
		       $strLen = (($strEndPos +6) - ($strBegPos + 17));
	    	       $strWork = trim(substr($strSearchData ,($strBegPos + 17), $strLen));
		       $strWork = trim(substr($strSearchData ,($strBegPos + 17), $strLen));
			echo '<BR><BR>$strWork...' . $strWork . '<BR><BR>';
			// count the nbr of whitespaces
			$wrkBlanks = '';
			$wrkCount = 0;
			$wrkCount = substr_count($strWork,' ');
			echo "nbr of blanks.. " . $wrkCount;
			for ($x = 0; $x <= $wrkCount; $x++) 
	    	        	{
			        	$wrkBlank = ($wrkBlanks . ' ');
                                 }
			$wrkArray = explode($wrkBlanks,$strWork);
			$wrkCnt = count($wrkArray);
                        echo '<BR>Array Count ' . $wrkCnt;
		        foreach($wrkArray as $key => $value)
                           {
                                echo 'Line values   ' . $key." has the value ". $value . '<BR><BR>';
                           }
			//$stripData = trim($wrkArray[1]);
	    }	
Screenshot_1.png
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros