Solved

Function cal in eregi_replace()

Posted on 2002-07-19
3
254 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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