Solved

Function cal in eregi_replace()

Posted on 2002-07-19
3
247 Views
Last Modified: 2012-05-04
Greetings all,

I need to call a function each time php replaces a string with ergei_replace. here is the code:

     # Mathes %HZE_*
     $RX_E_P = '%HZE_([[:alpha:]/_0-9]*)';
     # Mathes %HZI_*
     $RX_I_P = '%HZI_([[:alpha:]/_0-9]*)';
     # Mathes <HAZEL_DATE[*]>|<HAZEL-DATE[*]>
     $RX_D_P = '(<[[:space:]]*HAZEL_DATE[^>]*>)|(<[[:space:]]*HAZEL-DATE[^>]*>)';
     $DATE_VAR = 'HZDATE';
     reset($StringTemp);
     while(list($k,$v)=each($StringTemp))
     {
          if(eregi($RX_E_P,$v) && $v = str_replace('"','',eregi_replace($RX_E_P, (STRING) h3m_get("QUERY","\\1") ,$v)))
          {
               echo "$v\n";
               #$outTemp[$k] = '"'.h3m_get("QUERY","$v").'"';
          }
          elseif(!eregi($RX_D_P,$v) || !$outTemp[$k] = eregi_replace($RX_D_P,h3m_get("QUERY","$DATE_VAR"),$v))
          {
               $outTemp[$k] = $v;
          }

I Know that PHP is not calling the function because I have the function set to echo each time it is called and it isn't echoing.
thanks
~Jay
0
Comment
Question by:Deathead
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 100 total points
ID: 7169544
Can you try ...

while(list($k,$v)=each($StringTemp))
    {
    echo "$k=$v<br>";
    ...

just to make sure you are splitting correctly.


What does the h3m_get function return. Echo this out as well ...

while(list($k,$v)=each($StringTemp))
    {
    echo "$k=$v<br>" . h3m_get("QUERY","\\1") . "<br>" . h3m_get("QUERY","$DATE_VAR") . "<br>";
    ...

You might simply be missing some parenthesis...

Try ...


while(list($k,$v)=each($StringTemp))
    {
    if(eregi($RX_E_P,$v) && ($v = str_replace('"','',eregi_replace($RX_E_P, (STRING) h3m_get("QUERY","\\1") ,$v))))
         {
              echo "$v\n";
              #$outTemp[$k] = '"'.h3m_get("QUERY","$v").'"';
         }
         elseif(!eregi($RX_D_P,$v) || !($outTemp[$k] = eregi_replace($RX_D_P,h3m_get("QUERY","$DATE_VAR"),$v)))
         {
              $outTemp[$k] = $v;
         }
     }

Regards,

Richard.

P.S. what sort of values are you putting into $StringTemp and what is coming out of h3m_get?
0
 

Author Comment

by:Deathead
ID: 7169680
Richard,

I thank you for your comment. I have already found the proper solution which was to use the preg_replace() with the 'e' modifyer.

I will still award the points as your comments show that you were most definately trying to help.

Thank you again,
~Jay
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7169686
Thank you.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question