Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] duda con eliminar linea en .txt

Estas en el tema de duda con eliminar linea en .txt en el foro de PHP en Foros del Web. Hola a todos es que quiero eliminar todas las linea que comiensan con ; del .txt...
  #1 (permalink)  
Antiguo 31/05/2021, 21:36
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 766
Antigüedad: 12 años, 5 meses
Puntos: 10
duda con eliminar linea en .txt

Hola a todos es que quiero eliminar todas las linea que comiensan con ; del .txt
  #2 (permalink)  
Antiguo 01/06/2021, 01:46
Avatar de vb2005  
Fecha de Ingreso: noviembre-2005
Ubicación: Paderborn - Alemania
Mensajes: 568
Antigüedad: 19 años
Puntos: 25
Respuesta: duda con eliminar linea en .txt

Puedes dar más información de qué es lo que quieres lograr que tipos de strings son los que quieres reemplazar, pero como pista puedes usar substr_replace()
__________________
www.marcher.com.uy - Web personal
Nerd's Corner - Desarrollo de software a medida
  #3 (permalink)  
Antiguo 01/06/2021, 09:13
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 766
Antigüedad: 12 años, 5 meses
Puntos: 10
Respuesta: duda con eliminar linea en .txt

ok tengo el archivo

php.ini
Código php.ini:
Ver original
  1. [PHP]
  2. engine = On
  3. short_open_tag = Off
  4. asp_tags = Off
  5. precision = 14
  6. y2k_compliance = On
  7. output_buffering = 4096
  8. zlib.output_compression = Off
  9. implicit_flush = Off
  10. unserialize_callback_func =
  11. serialize_precision = 100
  12. allow_call_time_pass_reference = Off
  13. safe_mode = Off
  14. safe_mode_gid = Off
  15. safe_mode_include_dir =
  16. safe_mode_exec_dir =
  17. safe_mode_allowed_env_vars = PHP_
  18. safe_mode_protected_env_vars = LD_LIBRARY_PATH
  19. disable_functions =
  20. disable_classes =
  21. expose_php = On
  22. max_execution_time = 30
  23. max_input_time = 60
  24. memory_limit = 128M
  25. error_reporting = E_ALL & ~E_DEPRECATED
  26. display_errors = Off
  27. display_startup_errors = Off
  28. log_errors = On
  29. log_errors_max_len = 1024
  30. ignore_repeated_errors = Off
  31. ignore_repeated_source = Off
  32. report_memleaks = On
  33. track_errors = Off
  34. html_errors = Off
  35. variables_order = "GPCS"
  36. request_order = "GP"
  37. register_globals = Off
  38. register_long_arrays = Off
  39. register_argc_argv = Off
  40. auto_globals_jit = On
  41. post_max_size = 8M
  42. magic_quotes_gpc = Off
  43. magic_quotes_runtime = Off
  44. magic_quotes_sybase = Off
  45. auto_prepend_file =
  46. auto_append_file =
  47. default_mimetype = "text/html"
  48. doc_root =
  49. user_dir =
  50.  
  51. ; Directory in which the loadable extensions (modules) reside.
  52. ; http://php.net/extension-dir
  53. ; extension_dir = "./"
  54. ; On windows:
  55. ; extension_dir = "ext"
  56.  
  57. ; Whether or not to enable the dl() function.  The dl() function does NOT work
  58. ; properly in multithreaded servers, such as IIS or Zeus, and is automatically
  59. ; disabled on them.
  60. ; http://php.net/enable-dl
  61. enable_dl = Off
  62.  
  63. ; cgi.force_redirect is necessary to provide security running PHP as a CGI under
  64. ; most web servers.  Left undefined, PHP turns this on by default.  You can
  65. ; turn it off here AT YOUR OWN RISK
  66. ; **You CAN safely turn this off for IIS, in fact, you MUST.**
  67. ; http://php.net/cgi.force-redirect
  68. ;cgi.force_redirect = 1
  69.  
  70. ; if cgi.nph is enabled it will force cgi to always sent Status: 200 with
  71. ; every request. PHP's default behavior is to disable this feature.
  72. ;cgi.nph = 1
  73.  
  74. ; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
  75. ; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
  76. ; will look for to know it is OK to continue execution.  Setting this variable MAY
  77. ; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
  78. ; http://php.net/cgi.redirect-status-env
  79. ;cgi.redirect_status_env = ;
  80.  
  81. ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
  82. ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
  83. ; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
  84. ; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
  85. ; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
  86. ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
  87. ; http://php.net/cgi.fix-pathinfo
  88. ;cgi.fix_pathinfo=1
  89.  
  90. ; FastCGI under IIS (on WINNT based OS) supports the ability to impersonate
  91. ; security tokens of the calling client.  This allows IIS to define the
  92. ; security context that the request runs under.  mod_fastcgi under Apache
  93. ; does not currently support this feature (03/17/2002)
  94. ; Set to 1 if running under IIS.  Default is zero.
  95. ; http://php.net/fastcgi.impersonate
  96. ;fastcgi.impersonate = 1;
  97.  
  98. ; Disable logging through FastCGI connection. PHP's default behavior is to enable
  99. ; this feature.
  100. ;fastcgi.logging = 0
  101.  
  102. ; cgi.rfc2616_headers configuration option tells PHP what type of headers to
  103. ; use when sending HTTP response code. If it's set 0 PHP sends Status: header that
  104. ; is supported by Apache. When this option is set to 1 PHP will send
  105. ; RFC2616 compliant header.
  106. ; Default is zero.
  107. ; http://php.net/cgi.rfc2616-headers
  108. ;cgi.rfc2616_headers = 0
  109.  
  110. ;;;;;;;;;;;;;;;;
  111. ; File Uploads ;
  112. ;;;;;;;;;;;;;;;;
  113.  
  114. ; Whether to allow HTTP file uploads.
  115. ; http://php.net/file-uploads
  116. file_uploads = On
  117.  
  118. ; Temporary directory for HTTP uploaded files (will use system default if not
  119. ; specified).
  120. ; http://php.net/upload-tmp-dir
  121. ;upload_tmp_dir =
  122.  
  123. ; Maximum allowed size for uploaded files.
  124. ; http://php.net/upload-max-filesize
  125. upload_max_filesize = 2M

y quiero solo mostrar las lineas que no contengan comentado por la coma ;;;
  #4 (permalink)  
Antiguo 01/06/2021, 23:40
 
Fecha de Ingreso: junio-2012
Ubicación: En el Mundo
Mensajes: 766
Antigüedad: 12 años, 5 meses
Puntos: 10
Respuesta: duda con eliminar linea en .txt

ya encontre como poder hacerlo

Código PHP:
Ver original
  1. $data = file("php.ini");
  2. $out = array();
  3. foreach($data as $line) {
  4.      if (strpos($line, ';') === false ) {
  5.          $out[] = $line;
  6.      }
  7. }

Etiquetas: txt
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:51.