İçinde dizi ile aşağıdaki dizeyi oluşturmak nasıl?

0 Cevap php

Ben bir $ _GET söylemek bir dizi var

Array
        (
            [0] => 0
            [1] => 1
            [2] => 2
            [3] => 3
            [4] => 4
        )

bunun için ben bir dize oluşturmak için bu süre döngü kullanıyorum:

while (list($key, $value) = each($_GET)) {

          $get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

      }

I $ _GET bir dizi alırsanız Şimdi böyle diyorlar:

Array
(
    [0] => pid
    [1] => gid
    [2] => Array
        (
            [0] => 0
            [1] => 1
            [2] => 2
            [3] => 3
            [4] => 4
        )

)

then in this case what could be the possible changes be done to while loop so that I can avoid the result like this http://www.example.com/shopping_cart.php?0=pid&1=gid&2=Array in url when i use this to redirect it. I want the url to display the values properly..not like "2=Array".. how can i do this?

EDIT

Yardımın için teşekkürler millet, ama ben ne yeni bir işlev tanıtmak değil ben döngü için birlikte while döngüsü yerine Loop İKEN yeniden düzenleme verilen bana yardımcı olabilir, ben çok sev olurdu ...

EDIT 2

Ben oluşturulan url yönlendirme için header(location:$get_url) kullanıyorum, bu url içinde "2 = Array" ekran sorun?

EDIT 3

Sorguyu oluşturmak için kullanılan fonksiyonlar, NOT: Bu işlevler, osCommerce VE DAHİLİ İŞLEVİ ARE

Ben hala kullanımı ve fonksiyon tanımı aşağıya bakınız içine foreach döngü getirerek bunun birini değiştirildi:

function tep_redirect($url) {
    if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { 
      tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
    }

    if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
      if (substr($url, 0, strlen(HTTP_SERVER . DIR_WS_HTTP_CATALOG)) == HTTP_SERVER . DIR_WS_HTTP_CATALOG) { // NONSSL url
        $url = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . substr($url, strlen(HTTP_SERVER . DIR_WS_HTTP_CATALOG)); // Change it to SSL
      }
    }

    $url =  str_replace("&", "&", $url);

    header('Location: ' . $url);

    tep_exit();
  }

=========================

   function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
        global $request_type, $session_started, $SID, $spider_flag;

        if (!tep_not_null($page)) {
          die('</td></tr></table></td></tr></table><br><br><font color="#ff0000">' . TEP_HREF_LINK_ERROR1);
        }

        if ($connection == 'NONSSL') {
          $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
        } elseif ($connection == 'SSL') {
          if (ENABLE_SSL == true) {
            $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
          } else {
            $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
          }
        } else {
          die('</td></tr></table></td></tr></table><br><br><font color="#ff0000">' . TEP_HREF_LINK_ERROR2);
        }

        if (tep_not_null($parameters)) {
          while ( (substr($parameters, -5) == '&amp;') ) $parameters = substr($parameters, 0, strlen($parameters)-5);
          $link .= $page . '?' . tep_output_string($parameters);
          $separator = '&amp;';
        } else {
          $link .= $page;
          $separator = '?';
        }


        // if session is not started or requested not to add session, skip it
        if ( ($add_session_id == true) && ($session_started == true) ){

          // if cookies are not set and not forced, then add the session info incase the set cookie fails 
          if ( ! isset($_COOKIE[tep_session_name()]) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
            $_sid = tep_session_name() . '=' . tep_session_id();

          // if we are chaning modes and cookie domains differ, we need to add the session info
          } elseif ( HTTP_COOKIE_DOMAIN . HTTP_COOKIE_PATH != HTTPS_COOKIE_DOMAIN . HTTPS_COOKIE_PATH
                     &&
                     (
                       ( $request_type == 'NONSSL' && $connection == 'SSL' && ENABLE_SSL == true )
                       ||
                       ( $request_type == 'SSL' && $connection == 'NONSSL' )
                     )
                   ) {
            $_sid = tep_session_name() . '=' . tep_session_id();
          }

        }

        if (isset($_sid) && !$spider_flag) {
          $link .= $separator . tep_output_string($_sid);
        }

        return $link;
      }

===========================

function tep_get_all_get_paramtrs($exclude_array = '') {
    global $HTTP_GET_VARS;

    if (!is_array($exclude_array)) $exclude_array = array();

    $get_url = '';
    if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) 
    {
      reset($HTTP_GET_VARS);
      foreach($HTTP_GET_VARS as $key => $a)
      {
        if(is_array($a))
        {
            foreach($a as $k => $v)
            {
                $get_url[] = $key . '[]' . '=' . rawurlencode(stripslashes($v));
            }
        }
        else
        {
            $get_url[] = $key . '=' . rawurlencode(stripslashes($a));
        }
      }

   /*   while (list($key, $value) = each($HTTP_GET_VARS)) 
      {
      if(!is_array($value))
      {
        if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) 
        {
          $get_url .= $key . '=' . rawurlencode(stripslashes($value));
        }
      }
      else
      {

      if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) 
        {
          $get_url .= preg_replace('/#\d/','[]',http_build_query($value,$key.'#'));
        }
     /*     while(list($key1, $value1) = each($value))
        {
            if ( (strlen($value1) > 0) && ($key1 != tep_session_name()) && ($key1 != 'error') && (!in_array($key1, $exclude_array)) && ($key1 != 'x') && ($key1 != 'y') ) 
            {
              $get_url .= $key1 . '=' . rawurlencode(stripslashes($value1));
            }
        }*/
     /* }
      }*/
      $get_url .=  '&amp;';
    }

    return $get_url;
  }

========================

tep_redirect(tep_href_link($goto, tep_get_all_get_paramtrs($parameters)));

Burada $ parametreler url ekran mantığı ile hiçbir benzerliği yoktur iki değerlerle bir dizidir

0 Cevap