I'm working on a view in a laravel project (full project is available on github at https://github.com/wvulibraries/rockefeller-css/tree/trying-searchy/src/project-css) what I want to do is identify if the string contains a filename with a .txt extension and then strip out the path from the string. Leaving just filename.txt. We are importing a csv file and the path is going to be different for the file. What we want to to is load the files into a folder in storage and let the users click to view the file. An example from one record is "..\documents\BlobExport\formletters\vecr0601_concurrent_receipt.txt". I was going to try to use
$filename = end(explode('\',$rcrd->$clmnNme));
but it crashes the view ever time and gives "Parse error: syntax error, unexpected 'layouts' (T_STRING), expecting ',' or ')' (View: /var/www/html/project-css/resources/views/user/show.blade.php)". The current view is below.
@extends('layouts.default')
@section('content')
<!-- Search engine -->
@include('user/searchbox');
<!-- Separation -->
<hr/>
<div class="dataWrppr">
<div class="container">
<!-- Separation -->
<hr/>
@foreach($rcrds as $key => $rcrd)
<div class="col-xs-12 col-sm-12 col-md-12">
@foreach($clmnNmes as $key => $clmnNme)
@if (strpos($rcrd->$clmnNme, '.txt') !== FALSE)
@php
$filename = end(explode("\", $rcrd->$clmnNme));
@endphp
<h4><b>{{$clmnNme}}</b>: {{$rcrd->$clmnNme}} {{$filename}}</h4>
@else
<h4><b>{{$clmnNme}}</b>: {{$rcrd->$clmnNme}}</h4>
@endif
@endforeach
</div>
@endforeach
</div>
</div>
@endsection
The database cannot change it is being used for research so I cannot change it during the import. Any help would be appreciated.